Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 134
Add string-based level keys to Bunyan logger#3136
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
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
524c2497f73fa08add7ad0b4779f9191cb3972a8770c9a1adFile filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -262,7 +262,7 @@ const config = convict({ | ||
| doc: 'If we should print logs from sequelize', | ||
| format: Boolean, | ||
| env: 'printSequelizeLogs', | ||
| default: true | ||
| default: false | ||
Contributor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should we be defaulting to true? seems like we'll be missing some logs if this is set to false Contributor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @SidSethi@vicky-g this and the commonEnv.sh change is necessary so this doesn't send sequelize debug sql queries to loggly. with kube and fluentd this was never sent over. it was primarily a debugging tool and commonEnv.sh now enables it for local development but turns it off for live stage/prod environments Contributor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. gotcha, thanks for clarifying | ||
| }, | ||
| // Transcoding settings | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -3,13 +3,32 @@ const shortid = require('shortid') | ||
| const config = require('./config') | ||
| // taken from: https://github.com/trentm/node-bunyan/issues/194#issuecomment-347801909 | ||
| // since there is no official support for string-based "level" values | ||
| // response from author: https://github.com/trentm/node-bunyan/issues/194#issuecomment-70397668 | ||
| function RawStdOutWithLevelName() { | ||
| return { | ||
| write: (log) => { | ||
| // duplicate log object before sending to stdout | ||
| const clonedLog = Object.assign({}, log) | ||
SidSethi marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| // add new level (string) to level key | ||
| clonedLog.logLevel = bunyan.nameFromLevel[clonedLog.level] | ||
| const logLine = JSON.stringify(clonedLog, bunyan.safeCycles()) + '\n' | ||
Contributor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. once again, i see this safeCycles call in the linked examples, but no idea what it does Contributor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. looking at the documentation, looks like this is to show the keyword https://npmdoc.github.io/node-npmdoc-bunyan/build/apidoc.html#apidoc.element.bunyan.safeCycles | ||
| process.stdout.write(logLine) | ||
| } | ||
| } | ||
| } | ||
| const logLevel = config.get('logLevel') || 'info' | ||
| const logger = bunyan.createLogger({ | ||
| name: 'audius_creator_node', | ||
| streams: [ | ||
| { | ||
| level: logLevel, | ||
| stream: process.stdout | ||
| stream: new RawStdOutWithLevelName(), | ||
SidSethi marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| type: 'raw' | ||
| } | ||
| ] | ||
| }) | ||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
whats intent behind the change here and in config.js? seems like it will do the same thing right, i may be misunderstanding tho