Open
Description
MWE:
using Logging: Logging, @logmsg, LogLevel, with_logger, ConsoleLogger
with_logger(ConsoleLogger(LogLevel(-5_000))) do
@logmsg LogLevel(-3_000) "hello world"
end
I would expect this to print the log message, because I am using a custom task-local logger, and I expected my custom logger to override any global behavior. However, this MWE will result in no logs being printed.
Workaround
Here's a workaround:
using Logging: Logging, @logmsg, LogLevel, with_logger, ConsoleLogger
+ Logging.disable_logging(Logging.BelowMinLevel)
with_logger(ConsoleLogger(LogLevel(-5_000))) do
@logmsg LogLevel(-3_000) "hello world"
end
With the workaround, the log message is printed:
┌ LogLevel(-3000): hello world
└ @ Main REPL[3]:2
I still think this is a bug though. IMO, when using a custom logger (e.g. with with_logger() do ...
), the min_level of the custom logger should be the only thing that matters, and the global settings should not prevent log messages from being printed.
Related issues
Related: #34037