gatsby
gatsby copied to clipboard
feat(gatsby): Allow reporters to add metadata to logs
Description
This change allows us to report metadata alongside logs. Optionally passing a meta arg to our log methods will pass that data onto redux to be consumed later on. A method was added (addMetadata) to our reporter to add persistent metadata that's passed with every request.
Adding the following to our redux action shows how this metadata appears:
process.stdout.write(JSON.stringify({ level, text, meta }, null, 2) + `\n`)
success Execute page configs - 0.033s { "level": "ACTIVITY_SUCCESS",
"text": "Caching Webpack compilations",
"meta": {
"versions": {
"gatsby": "4.22.0-next.4-dev-1660764647375"
}
}
}
success Caching Webpack compilations - 0.000s {
"level": "ACTIVITY_SUCCESS",
"text": "run queries in workers",
"meta": {
"versions": {
"gatsby": "4.22.0-next.4-dev-1660764647375"
}
}
}
success run queries in workers - 0.038s - 1/1 26.54/s {
"level": "ACTIVITY_SUCCESS",
"text": "Merge worker state",
"meta": {
"versions": {
"gatsby": "4.22.0-next.4-dev-1660764647375"
}
}
}
success Merge worker state - 0.003s {
"level": "ACTIVITY_SUCCESS",
"text": "Writing page-data.json files to public directory",
"meta": {
"versions": {
"gatsby": "4.22.0-next.4-dev-1660764647375"
}
}
}
This is like #35223, but adds persistent data and removes the silent log level.
Going to move this to just be on activities... Please hold. ⚠️
Closing out as stale