Skip to content

@safe_debug does not always work well with LoggingExtras.jl #723

@haakon-e

Description

@haakon-e

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions