Status Update
Comments
el...@google.com <el...@google.com> #2
ma...@aivora.es <ma...@aivora.es> #3
I'm assuming if this feature is implemented, we will get access to download the private key for any Google managed certificate that was generated with the:
gcloud compute ssl-certificates create
command as well.
ma...@aivora.es <ma...@aivora.es> #4
am...@google.com <am...@google.com> #5
ma...@aivora.es <ma...@aivora.es> #6
ma...@aivora.es <ma...@aivora.es> #7
mt...@google.com <mt...@google.com> #8
Looks like there are two issues here. The original issue about structured logging with console.log, and another about errors not being logged when the function crashes.
For the latter, could you provide some details? Which Node.js runtime are you using, for example?
ja...@google.com <ja...@google.com> #9
Structured logging via console.log()
should work today using Node.js 10 and above. I'm not certain about Node.js 8.
ti...@gmail.com <ti...@gmail.com> #10
At the potential risk of further conflating unrelated issues, I wonder if the original poster was referencing a problem with Structured Logging and Error Reporting. Structured logging does work, in the sense that the structured log entries are written and accessible in Logs Explorer. However, Error Reporting does not pick up structured logs with severity ERROR. For instance, all of the following result in log entries, none of them result in new entries in Error Reporting:
// console.error(JSON.stringify({severity: "ERROR", error: new Error("Case 5: I failed you")}));
// console.error(JSON.stringify({severity: "ERROR", error: new Error("Case 6: I failed you\nAnd because of that newline, I failed to alert you that I failed you.")}));
// const error7 = new Error("Case 7: I failed you");
// console.error(JSON.stringify({severity: "ERROR", message: error7.message, error: error7}));
// const error8 = new Error("Case 8: I failed you\nAnd because of that newline, I failed to alert you that I failed you.");
// console.error(JSON.stringify({severity: "ERROR", message: error8.message, error: error8}));
// console.error(JSON.stringify({severity: "ERROR", message: "Case 9: I failed you"}));
// console.error(JSON.stringify({severity: "ERROR", message: "Case 10: I failed you\nAnd because of that newline, I failed to alert you that I failed you."}));
(These were originally test cases regarding the newline, which is relevant to another issue tracker I am in the process of entering -- but turns out is distinct from the structured logging cases here.)
Description
At this time, in a Cloud Function environment, I would recommend using console.log. You can still use structured logging when you do so:
console.log(JSON.stringify({ severity: 'ERROR', textPayload: 'hello world' })) console.log(JSON.stringify({ severity: 'CRITICAL', name: "john", lastname: "smith" }))
Using console.log should ensure that logs are drained synchronously, which is not currently possible with the @google-cloud/logging library.