Selectively enable debug level logging with a custom `global_logger`

the ENV["JULIA_DEBUG"] thing is a mess, that @c42f have been talking about replacing for years.
See DemuxLogger does not work with JULIA_DEBUG? · Issue #20 · JuliaLogging/LoggingExtras.jl · GitHub

I suggest LoggingExtras is a much better solution.
I would do something like (not tested).

using LoggingExtras

global_logger(EarlyFilteredLogger(ConsoleLogger(stdout, BelowMinLevel)) do log
    # Keep any messages from MyModule or of Info level or greater
    log._module == MyModule || log.level >= Info
end)
1 Like