-
Notifications
You must be signed in to change notification settings - Fork 36
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
fix: replace bunyan logger #1447
base: main
Are you sure you want to change the base?
Conversation
a34cab4
to
5e5f845
Compare
c756449
to
accb4aa
Compare
@@ -267,9 +267,11 @@ exports.sendSpans = function sendSpans(spans, cb) { | |||
if (err && !maxContentErrorHasBeenLogged && err instanceof PayloadTooLargeError) { | |||
logLargeSpans(spans); | |||
} else if (err) { | |||
logger.debug('Failed to send: %s', getSpanLengthInfo(spans)); | |||
const obj = getSpanLengthInfo(spans); |
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.
Pino does not support concatenated strings using %s
if an object is passed instead of a string.
* Custom write method to send logs to multiple destinations | ||
* @param {string} chunk | ||
*/ | ||
write(chunk) { |
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.
custom write method which writes the log to stdout and agent stream function (pinoToAgentStream)
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.
I tried implementing this use case using pino.transport, pino.destination and pino.multistream etc. And finally ended up with the current implementation which is working as expected like previous bunyan stream
@@ -31,40 +31,57 @@ const registry = {}; | |||
* @param {boolean} [isReInit] | |||
*/ | |||
exports.init = function init(config, isReInit) { | |||
const consoleStream = pino.destination(1); |
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.
If multistream is used, we need to specify the log streams where it is going. Here this is defined for logging into the process.stdout
parentLogger = pino( | ||
{ | ||
...parentLogger.levels, | ||
base: parentLogger.bindings() |
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.
if we want to change something in pino logger after it is initialized, we need to create a new logger and assign initial logger bindings to it
%s
and correct it