When I log something with console.warn()
it seems to appear in the Stackdriver logs with severity "ERROR". The Stackdriver Error Reporting does not show these errors, so it seems there they are not considered errors. This makes it impossible to filter the logs to only show me errors.
Reading the Stackdriver logging docs I get the impression that I'm not supposed to use the plain javascript console functions but instead use Bunyan. Is that correct? I didn't read anywhere that I shouldn't.
I have since learned from Google support that things changed (at least for cloud functions) since Node 10. Node 8 still logged correctly with console.info getting level info and console.warn getting level warning, and that seems to align with my experience.
In recent versions of firebase-functions there is the logger library which you should use for writing logs. For non-firebase environments you can use @google-cloud/logging which seems essentially the same thing. You then have full control over severity level as well as the ability to log extra JSON payload as the second parameter.
So in other words, don't use the native Javascript console methods.