nest-winston icon indicating copy to clipboard operation
nest-winston copied to clipboard

How can we pass winston instance to nest-winston?

Open Farshid-Far opened this issue 2 years ago • 1 comments

I did not find a way to do that, I want to use some winston features. We can provide winstonInstance to express-winston (similar library: https://github.com/bithavoc/express-winston), I am looking for such kind of property or anything else which can help me.

Farshid-Far avatar May 13 '22 08:05 Farshid-Far

Hello, you mean you want to access the underlying winston instance? Can you provide an example of what you are trying to achive?

gremo avatar May 13 '22 12:05 gremo

Hello, I think I understand the request as I have the same need right now.

In my case, I would like to provide to the function WinstonModule.createLogger({...}) an actual instance of Winston instead of the options needed to create a new one. So, this would mean:

WinstonModule.createLogger({
  winstonInstance: myWinstonInstance
})

This what express-winston linked above allows.

My main reason for that is the following: I need some way to access the Winston instance in order to update the level field. The goal is to allow to change the "minimum" level of logs at runtime in order to ease the debug in production. The easiest seems to create the Winston instance beforehand and keep it in a variable before giving it to WinstonModule, so that we can still interact with it.

What do you think ?

GuillaumeDecMeetsMore avatar Oct 11 '22 12:10 GuillaumeDecMeetsMore

Hi - I was trying to use this new feature and realised the instance parameter was being ignore when using either forRoot or forRootAsync. I've opened a PR to modify the behaviour.

Does this look ok? Or have I misunderstood the desired behaviour?

leocurrie avatar Jan 11 '23 14:01 leocurrie

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 7 days.

github-actions[bot] avatar Jun 30 '23 01:06 github-actions[bot]

This issue was closed because it has been stalled for 7 days with no activity.

github-actions[bot] avatar Jul 07 '23 01:07 github-actions[bot]