You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
log level formatting in functions emulator and shell #1800
It would be nice to have better formatting in the shell when using console.log , console.error, ... For instance, colors or prefix to differentiate log levels.
It is of course possible to wrap native console behavior (I am using loglevel and loglevel-plugin-prefix), but applying different colors does not work.
Also, one need to detect it we are running locally from funtions:shell or as deployed function for not duplicating log level indicator and timestamp displayed in the web-based logs viewer.
@christophe-g thanks for following up on your email! This is a reasonable feature request. I think my personal preference would be for a label over colors (since not everyone uses a colorful terminal) but it's not a strong preference.
I like the idea of differentiating via symbols, and I'd further suggest some formatting (example below) to make the logs easy to read:
log 1: blah blah blah
second line of blah blah blah
third line of blah
log 2: easy to find b/c of indent
log 3: blah blah blah
vs
log 1: blah blah blah
second line of blah blah blah
a third line line of blah
log 2: less easy to find without indent
log 3: blah blah blah
This is already available in the online (i.e. non-emulated) function logs, in the sense that when you click the arrow to expand the log information, the expanded info stays in its column. In the terminal, there would be no such GUI, so that would presumably have to be built into the formatting.
FYI, here's a StackOverflow question which is related to viewing Firebase emulator logs in browser devtools.
I'm not suggesting that should be answered here, but people who arrive here looking for a richer logging/debugging experience might benefit from whatever information shows up there.
And, if that turns out to be a viable option, it might obviate the need for (some) of the functionality being discussed in this thread being build into the CLI.
@abeisgoat do you want to handle this since you're now Logging Czar? We currently use the > prefix for user logs but many people have said it would be more useful to have some sort of [c.log] prefix.
Activity
samtstern commentedon Nov 15, 2019
@christophe-g thanks for following up on your email! This is a reasonable feature request. I think my personal preference would be for a label over colors (since not everyone uses a colorful terminal) but it's not a strong preference.
christophe-g commentedon Nov 16, 2019
@samtstern - thanks a lot.
What about smth similar to the web.
.
It seems it is kind of already in place. From
lib/util.js:ultraGentle commentedon Dec 17, 2019
I like the idea of differentiating via symbols, and I'd further suggest some formatting (example below) to make the logs easy to read:
vs
This is already available in the online (i.e. non-emulated) function logs, in the sense that when you click the arrow to expand the log information, the expanded info stays in its column. In the terminal, there would be no such GUI, so that would presumably have to be built into the formatting.
[-]log level formatting in functions:shell[/-][+]log level formatting in functions emulator and shell[/+]ultraGentle commentedon Dec 19, 2019
FYI, here's a StackOverflow question which is related to viewing Firebase emulator logs in browser devtools.
I'm not suggesting that should be answered here, but people who arrive here looking for a richer logging/debugging experience might benefit from whatever information shows up there.
https://stackoverflow.com/questions/59413448/using-node-inspect-to-attach-firebase-emulated-functions-to-browser-devtools
And, if that turns out to be a viable option, it might obviate the need for (some) of the functionality being discussed in this thread being build into the CLI.
ultraGentle commentedon Dec 19, 2019
Wow, that question was already answered, and is indeed relevant to this issue.
Firebase tools 7.11.0 introduces the ability view logs and debug from browser devtools.
The reason that's relevant to this issue is that devtools differentiate
console.logwarnetc., and furthermore links to the relevant spot inindex.js.So, for me, at least, this update is sufficient (and most welcome!).
samtstern commentedon Mar 19, 2020
@abeisgoat do you want to handle this since you're now Logging Czar? We currently use the
>prefix for user logs but many people have said it would be more useful to have some sort of[c.log]prefix.samtstern commentedon Apr 2, 2020
@ultraGentle @christophe-g we have a new feature related to emulator logging in Alpha that I'd love to get your opinion on.
If you email me at samstern [at] google [dot] com I will invite you to the Alpha!
Oh and you'll also need to fill this out (if you never have before): https://services.google.com/fb/forms/firebasealphaprogram/