Console.log calls result in multiple log entries where a single entry is expected
See original GitHub issueConsole.log calls that end up with newlines in them cause multiple log entries rather than single (collapsed) log entries. Logging a string with newlines causes this, as does logging a “large enough” object (which seems to get stringified differently to a “small enough” object to get newlines in its output).
I also note that the log type field is ?
rather than I
as is was under node 8.
The log outputs below were produced by just changing between "engines": { "node": "8" }
and "engines": { "node": "10" }
, and deploying, with no other changes.
Related issues
none
Version info
node:
v10.15.3
firebase-functions:
3.3.0
firebase-tools:
7.12.1
firebase-admin:
8.9.0
Test case
exports.test = functions.https.onRequest((req, res) => {
console.log('multiple lines', 'line one\nline two\nline three')
console.log('small object', { one: 'one', two: 'two', three: 'three' })
console.log('object', { one: 'one', two: 'two', three: 'three', four: 'four', five: 'five', six: 'six' })
res.send({})
})
Steps to reproduce
deploy test function call test function view log
Expected behaviour
single log entries (as per node8 version)
2020-01-20T00:31:29.897645002Z D test: Function execution started
2020-01-20T00:31:29.907Z I test: multiple lines line one
line two
line three
2020-01-20T00:31:30.004Z I test: small object { one: 'one', two: 'two', three: 'three' }
2020-01-20T00:31:30.005Z I test: object { one: 'one',
two: 'two',
three: 'three',
four: 'four',
five: 'five',
six: 'six' }
2020-01-20T00:31:30.006307295Z D test: Function execution took 109 ms, finished with status code: 200
Actual behavior
multiple log entries for “large enough” objects, or any string with newlines
2020-01-20T00:29:01.446537764Z D test: Function execution started
2020-01-20T00:29:01.791Z ? test: multiple lines line one
2020-01-20T00:29:01.792Z ? test: line two
2020-01-20T00:29:01.792Z ? test: line three
2020-01-20T00:29:01.795Z ? test: small object { one: 'one', two: 'two', three: 'three' }
2020-01-20T00:29:01.795Z ? test: object { one: 'one',
2020-01-20T00:29:01.795Z ? test: two: 'two',
2020-01-20T00:29:01.795Z ? test: three: 'three',
2020-01-20T00:29:01.795Z ? test: four: 'four',
2020-01-20T00:29:01.795Z ? test: five: 'five',
2020-01-20T00:29:01.795Z ? test: six: 'six' }
2020-01-20T00:29:01.802375869Z D test: Function execution took 356 ms, finished with status code: 200
Were you able to successfully deploy your functions?
yes, no errors
Issue Analytics
- State:
- Created 4 years ago
- Reactions:67
- Comments:40 (13 by maintainers)
If you put
at the top of your functions code with the latest version of the sdk logging should work as it did before in node 10. You can also use the new logging SDK to take advantage of structured logging support
On Fri, Jun 19, 2020, 6:53 AM Ashemah Harrison notifications@github.com wrote:
We are working on a new logging SDK for Cloud Functions for Firebase that will support richer logging and proper multiline logs. Stay tuned!
On Thu, May 21, 2020, 5:47 PM David Clark notifications@github.com wrote: