I'm currently developing a project using Go and I've set up logging using the "slog" package but I can't figure out how to do it programmatically Retrieve the current log level.
I want to use something like:
lvl := slog.GetLogLevel()
But the aove function does not exist. Is it possible to retrieve the current log level programmatically?
You can use slog.Default().Enabled()
to check if you want to log a certain level. The log level is retained within the handler, and no method is provided to obtain handler options.
The above is the detailed content of How to retrieve log level using 'slog' package in Go?. For more information, please follow other related articles on the PHP Chinese website!