Closed jaredallard closed 8 months ago
Since Log is just a handler to log/slog, you can dynamically change the Log instance level using SetLevel(level)
There is one feature I like with Leveler it is because when it is cloned with .With(...)
, only the reference gets cloned and so, using LevelVar, it is possible to change the level of all loggers at once.
Basically, sub-loggers are following the super one in terms of log level.
To give more context, I create loggers using a global var
instance which is apparently loaded before the config is. Might be a skill issue on my part and I should make my config also be loaded as a global var, however, being able to change the log level dynamically at once everywhere might be a good idea too.
It'd be nice if one could use
slog.Leveler
to control the log level of the logger!