Skip to content

Commit

Permalink
[INF-93] Follow up code cleanliness for Bunyan changes (#3144)
Browse files Browse the repository at this point in the history
* follow up fixes

* link to safeCycles()
  • Loading branch information
joaquincasares authored May 24, 2022
1 parent 0afdaa2 commit 60e2e3b
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions creator-node/src/logging.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,14 @@ function RawStdOutWithLevelName() {
return {
write: (log) => {
// duplicate log object before sending to stdout
const clonedLog = Object.assign({}, log)
const clonedLog = { ...log }

// add new level (string) to level key
clonedLog.logLevel = bunyan.nameFromLevel[clonedLog.level]

// stringify() uses the safeCycles() replacer, which returns '[Circular]'
// when circular references are detected
// related code: https://github.com/trentm/node-bunyan/blob/0ff1ae29cc9e028c6c11cd6b60e3b90217b66a10/lib/bunyan.js#L1155-L1200
const logLine = JSON.stringify(clonedLog, bunyan.safeCycles()) + '\n'
process.stdout.write(logLine)
}
Expand All @@ -27,7 +30,7 @@ const logger = bunyan.createLogger({
streams: [
{
level: logLevel,
stream: new RawStdOutWithLevelName(),
stream: RawStdOutWithLevelName(),
type: 'raw'
}
]
Expand Down

0 comments on commit 60e2e3b

Please sign in to comment.