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

Why should we bind this to a custom logger? it should be the logger object itself right? #123

Open
lokesh1729 opened this issue Jan 12, 2023 · 0 comments

Comments

@lokesh1729
Copy link

Hey,

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.

Winston is setting this to DerviedLogger instance if it is undefined - https://github.com/winstonjs/winston/blob/master/lib/winston/create-logger.js#L73

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant