Closed lox closed 1 month ago
Thanks - fixed in #620 - we still need to do a release so I'll leave this open for now.
Tested, this works great. Going to cut the release.
Fixed in 3.4.1.
Good morning,
We are sill experiencing this issue in cloud functions framework (NODE) version 3.4.1. We are not using firebase, only GCP with the code below
We leave here the example that we are testing:
const functions = require('@google-cloud/functions-framework');
functions.http('main', (req, res) => {
console.warn("I should be a warning in the logs")
res.send(`Hello ${req.query.name || req.body.name || 'World'}!`);
});
Any suggestion/update?
Best regards.
To handle log levels correctly in log explorer, use structured logging (or the firebase logging library); all the nodejs console
logging facilities are just writing a colored message to either stdout or stderr, so there's little we can do to tag logs with these APIs with the correct log level
We've never handled console.warn
in cloud logging/structured logs. Before 3.4.0, this showed as a log at "default" level.
After 3.4.0, this shows as an error, which is not really correct either. Neither have ever shown console.warn
as a warning.
We could consider changing this to show default log levels for unstructured logs as before 3.4.0 if this is breaking you. Would you prefer that?
We could also try to be clever and use the ANSI color codes at the start of the string to try to figure out if it's a warn or error, and add structured logging accordingly. might be cool, but also isn't backwards compatible.
First of all, thanks @jrmfg for your answer, we will change to structured logs if it is not supported warn in unstructured logs .
Well, we change to structured logging using Google Library, but is there a way to put a message and extra information without put the message in a sublevel as a simple string do it?
but is there a way to put a message and extra information without put the message in a sublevel as a simple string do it?
I'm not sure what you mean - the code you provided looks good, what problem are you having with it?
rolled back the stderr change in #625; it should land in 3.4.2.
See https://github.com/firebase/firebase-functions/issues/1580
Full reproduction at https://github.com/patientnotes/gcp-case-52054407