To use a custom logger, I see the below line in the documentation
logger: logger.info.bind(this)
I am wondering about the value of "this" would vary depending on the context right? when I used setGlobalConfig function with Winston logger instance, this is passed as undefined to DerivedLogger.
So, It should be logger.info.bind(logger) instead of this right? can you please explain why we should use this? Are we sure that this will be undefined every time?
Hey,
To use a custom logger, I see the below line in the documentation
I am wondering about the value of "this" would vary depending on the context right? when I used
setGlobalConfig
function with Winston logger instance,this
is passed asundefined
toDerivedLogger
.Winston is setting
this
toDerviedLogger
instance if it is undefined - https://github.com/winstonjs/winston/blob/master/lib/winston/create-logger.js#L73So, It should be
logger.info.bind(logger)
instead ofthis
right? can you please explain why we should use this? Are we sure thatthis
will beundefined
every time?