Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Log messages below LogLevel(-1_000) are ignored, even when a custom task-local logger is used #52234

Open
DilumAluthge opened this issue Nov 19, 2023 · 0 comments
Labels
bug Indicates an unexpected problem or unintended behavior logging The logging framework

Comments

@DilumAluthge
Copy link
Member

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

@DilumAluthge DilumAluthge added bug Indicates an unexpected problem or unintended behavior logging The logging framework labels Nov 19, 2023
@DilumAluthge DilumAluthge changed the title Log messages below -1_000 are ignored, even when a custom task-local logger is used Log messages below LogLevel(-1_000) are ignored, even when a custom task-local logger is used Nov 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Indicates an unexpected problem or unintended behavior logging The logging framework
Projects
None yet
Development

No branches or pull requests

1 participant