Skip to content
This repository has been archived by the owner on May 28, 2024. It is now read-only.

Support configuring loggers #413

Open
pierredelisle7 opened this issue Feb 10, 2021 · 1 comment
Open

Support configuring loggers #413

pierredelisle7 opened this issue Feb 10, 2021 · 1 comment

Comments

@pierredelisle7
Copy link

See google-home/smarthome-washer#39 for background information.

The ask is for the node.js smarthome client library to support configuring its various loggers (debug, info, warn, error).

The ability to configure the loggers would, for example, allow client applications that use firebase cloud functions to improve substantially the readability of their logs as is shown below.

Currently, one log message coming from this client library appears with multiple log entries in the "firebase cloud functions log console" which impacts readability substantially:

Current logs

If logging were configurable (PR coming shortly), log messages from this library would have a single log entry, which improves readability tremendously:

NewFunctionLogs

pierredelisle added a commit to pierredelisle/actions-on-google-nodejs that referenced this issue Feb 10, 2021
(actions-on-google#413).

With that change, a client application that uses Firebase cloud functions would simply need to do the following to improve substantially the readability of log entries in the cloud functions logs console:

const app = smarthome({
  debug: true,
  logs: {
    debug: functions.logger.debug,
    info: functions.logger.info,
    // 'warn' maps to 'error' in firebase logs.
    // If set to functions.logger.warn, there is no level associated with the log entry.
    warn: functions.logger.error,
    error: functions.logger.error
  }
});
@proppy
Copy link
Contributor

proppy commented Feb 12, 2021

It would be interesting to see if we can leverage the existing framework abstraction:
https://github.com/actions-on-google/actions-on-google-nodejs/tree/master/src/framework

To automatically use the Firebase Cloud Functions logger SDK when detected that we're deployed in a Firebase Cloud Functions environment.

Looks like this is currently done by running framework specific checks againt the arguments of the handler:
https://github.com/actions-on-google/actions-on-google-nodejs/blob/master/src/assistant.ts#L74

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants