Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Read log entries from jsonPayload and protoPayload. (firebase#3539)
Today, function logs with structured data (e.g. those generated using firebase-functions SDK's logger api) do not show up in `firebase functions:log` command: ```js // index.js exports.hello = functions.https.onRequest((request, response) => { info("Hello logs!", {structuredData: true}); info("hello world!"); response.send("Hello from Firebase!"); }); ``` ```bash $ firebase functions:log 2021-06-30T12:47:42.955491814Z D hello: Function execution started 2021-06-30T12:47:43.050Z I hello: # LOOK HERE: where's the message? 2021-06-30T12:47:43.050Z I hello: hello world! 2021-06-30T12:47:43.061418239Z D hello: Function execution took 107 ms, finished with status code: 200 ``` This happens because structured log entries are stored in [`jsonPayload` field](https://cloud.google.com/logging/docs/structured-logging), not `textPayload` field. In addition to correctly parsing `jsonPayload` field, we will also correctly parse log entries with `protoPayload` fields (in most cases, these log entries come from audit logs). *After* ```bash 2021-06-30T12:47:42.955491814Z D hello: Function execution started 2021-06-30T12:47:43.050Z I hello: {"message":"Hello logs!","structuredData":true} 2021-06-30T12:47:43.050Z I hello: hello world! 2021-06-30T12:47:43.061418239Z D hello: Function execution took 107 ms, finished with status code: 200 ```
- Loading branch information