phuslu / log

Fastest structured logging
MIT License
672 stars 44 forks source link

How about supporting global level? #52

Closed MisLink closed 2 years ago

MisLink commented 2 years ago

Setting level to a specific logger is not very useful, normally we want to change level for all created logger. There is no way to do it currently.

phuslu commented 2 years ago

no plan. i think log.DefaultLogger.SetLevel(l) is enough for most users.

let us keep eyes on this issue, if needed, let me add a .SetLevelRef(p *uint32) to this lib.

MisLink commented 2 years ago

Here is my use case: We have a client program which its logger level can be changed by remote for debugging. It contains many modules (we call them plugins) own the copy of logger with the Context marked the plugin.

phuslu commented 2 years ago

Got it, let expose a global method, log.SetLevelForAllLoggers(l), it use atomic change a hidden global unit32 inside this lib, then all logger slient() method will respect it.

Make sense?

MisLink commented 2 years ago

Sounds great. Actually, I implement it in the same way: #53

phuslu commented 2 years ago

thanks! Will look today.

phuslu commented 2 years ago

In consideration of performance, let me close this request for now, until we could find a better way. thanks again!