feat req: log/slog
: adding support for quiet log level
#69227
Labels
log/slog
: adding support for quiet log level
#69227
Proposal Details
In some use cases, you want to suppress (discard) all the logs outputs. However,
log/slog
does not support this quiet log level, but you can create a custom one implementing the quiet behavior.My original
InitLogger
method without support forquiet
This is my original
InitLogger
method, with the supportedlog/slog
levelsdebug
,info
,warn
,error
I call the method like this, for example in my cobra CLI:
And I set the log level thanks to a cobra flag
--log-level=info|debug...
My workaround: adding a custom
quiet
log levelThe workaround is fine. It is just a bit less elegant since I need to define
slog.NewTextHandler
for each 5 cases of the switch case. I do not know if I can achieve something better.I believe it should be possible to add this
quiet
log level somewhere in the filesrc/log/slog/level.go
.But I am not a Golang contributor, and I do not know how to implement this.
cc @jba , since you made the proposal #56345, you might have an opinion or you migh know who could be interested.
I seem to be duplicating #62005
I missed it while searching the current issues.
The text was updated successfully, but these errors were encountered: