Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve Logs readability #39

Closed
pierredelisle7 opened this issue Feb 8, 2021 · 4 comments
Closed

Improve Logs readability #39

pierredelisle7 opened this issue Feb 8, 2021 · 4 comments

Comments

@pierredelisle7
Copy link

In the codelab documentation at https://codelabs.developers.google.com/codelabs/smarthome-washer/#5, the log for a smarthome request shows an “info” log with the details of the Request object as shown below:

Screen Shot 2021-02-08 at 9 34 09 AM

However, when running the codelab, the request object is not shown:

LogWithoutDebug

Digging into the code, it appears that option “debug” must be enabled when instantiating smarthome, as shown below:

const app = smarthome({ debug: true });

However, after this is done, one will quickly notice readability issues of the log entries. Unfortunately, one log message appears with multiple log entries as shown below:

LogWithDebug

This appears to be caused by the fact that the smarthome node.js client library (actions-on-goole-nodejs) uses console.log(). These readability issues are mentioned in the Cloud Functions documentation “Write and view logs”. It is suggested the following:

With console.log, you may notice issues in the readability of your logs when migrating from the Node.js 8 runtime to Node.js 10 or 12. To work around this temporarily, add the following library to your functions:
require("firebase-functions/lib/logger/compat");
The recommended long-term solution for migrating to Node.js 10 or 12 is to refactor code to use the logger SDK.

The codelab does not use console.log() so this does not apply here. Rather, it is the use of console.log() in the node.js client library that is the issue.

Given that, would be great to do the following:

  • update documentation to clarify that app option “debug” must be set to true to see request and header details when the smarthome endpoint is called.
  • Ideally, the node.js smarthome client could be configured to use the cloud functions logging mechanism. For that, I’ll follow up with an issue at https://github.com/actions-on-google/actions-on-google-nodejs.
@proppy
Copy link

proppy commented Feb 10, 2021

Another possibility woudl be to mark debug: false and implement more specific logging in the codelab itself as we recently did in the sample:
google-home/smart-home-nodejs@903be16

@pierredelisle
Copy link

Agree that this is another possibility.

Personally, I think it would be great if all log messages (debug, info, warn, error) coming from the smart-home nodejs client library worked well with firebase cloud functions, or any other log console for that matter. Making the loggers configurable makes this possible without requiring client applications to add additional log messages to obtain information that is already reported by the smart-home nodejs client library.

I just filed this issue and the associated PR @ actions-on-google-nodejs for one possible approach.

@proppy
Copy link

proppy commented Feb 12, 2021

In the shorterm, may be we should just turn debug: true for this codelab and import require("firebase-functions/lib/logger/compat"); ?

@pierredelisle
Copy link

Obsolete at this point.

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

No branches or pull requests

3 participants