Commit bd98505
authored
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
```1 parent 8680f9b commit bd98505
2 files changed
+5
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| 8 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
48 | 48 | | |
49 | 49 | | |
50 | 50 | | |
51 | | - | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
52 | 55 | | |
53 | 56 | | |
54 | 57 | | |
| |||
0 commit comments