Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[INF-93] Follow up code cleanliness for Bunyan changes #3144

Merged
merged 2 commits into from
May 24, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
joaquincasares marked this conversation as resolved.
Show resolved Hide resolved
// 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