Terminate after warning is thrown - global setting

You can install a custom logger that eg. terminates the process for messages with level higher than warnings:

julia> using Logging, LoggingExtras

julia> terminator = EarlyFilteredLogger(global_logger()) do log_args
           if log_args.level >= Logging.Warn
               println(stderr, "ERROR: Log message with higher level than Logging.Warn, terminating process.")
               exit(-1)
           end
           return true
       end;

julia> global_logger(terminator);

julia> @info "hello"
[ Info: hello

julia> @warn "world"
ERROR: Log message with higher level than Logging.Warn, terminating process.

$ # back to shell prompt
3 Likes