-
Notifications
You must be signed in to change notification settings - Fork 57
Open
Labels
Description
I use LoggingExtras.jl for fine-grained logging control. In the following instance, it seems it does not play well with GPUCompiler.jl
's @safe_debug
:
# julia
# ]activate --temp
# ] add GPUCompiler, LoggingExtras
using GPUCompiler, Logging, LoggingExtras
# Define a custom filter logger
console_logger = Logging.ConsoleLogger(stdout, Logging.Debug) # deliberately set to debug
info_logger = LoggingExtras.EarlyFilteredLogger(log -> log.level >= Logging.Info, console_logger) # here, I filter out anything below Info
global_logger(info_logger)
# in Julia REPL, test some logging levels:
julia> @info "hi"
[ Info: hi
julia> @debug "hi" # no output
julia> GPUCompiler.@safe_debug "hi"
┌ Debug: hi
└ @ Main REPL[50]:1
The example above is a bit contrived because I obviously could achieve this using Logging.ConsoleLogger(stdout)
. In my actual code, I am using LoggingExtras.TeeLogger
to write to file and stdout simultaneously, e.g.:
logger = LoggingExtras.TeeLogger((
LoggingExtras.FileLogger("info.log"), # if I comment out this line, then @safe_debug, below, doesn't print
Logging.ConsoleLogger(stdout)
))
global_logger(logger)
julia> GPUCompiler.@safe_debug "hi"
┌ Debug: hi
└ @ Main REPL[74]:1
Julia Version 1.11.5, GPUCompiler v1.6.1, LoggingExtras v1.1.0