-
Notifications
You must be signed in to change notification settings - Fork 167
Functions Framework v3.4.0 breaks logging in Firebase projects #617
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
Comments
`firebase-functions/logger` writes structured logs to stdout and stderr by default, and makes these pretty with ANSI color codes. When functions-framework intercepts these messages to assign execution IDs, it handles them incorrectly in two ways. First, when the log emitted on stdout or stderr is already a structured log, we override (ignore) the severity set by the logger. This commit avoids changing severity if it's already set. Second, when parsing the message and attempting to determine if it's already a json object/structured log, it doesn't handle ANSI escape codes (https://en.wikipedia.org/wiki/ANSI_escape_code) used to control color, so parsing these will fail. This means that severity handling falls back to just looking at whether the message came from stdout or stderr, so debug-level and warn-level logs aren't handled correctly. This commit strips all ANSI escape codes that control terminal color. This is a minor bummer because it's a whole lot less pretty, but color-coding and smarter color coding generally seems less important than correct log-level handling. Fixes #617.
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. |
To handle log levels correctly in log explorer, use structured logging (or the firebase logging library); all the nodejs We've never handled 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? |
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 firebase/firebase-functions#1580
Full reproduction at https://github.com/patientnotes/gcp-case-52054407
The text was updated successfully, but these errors were encountered: