Creating a custom log message categorie

I also got this error with 1.6. I worked around it by extending handle_message. At top of file imported the function:

import Base.CoreLogging.handle_message

My custom level struct is this:

struct CustomLevel
    level::Int32
    name::String
end
handle_message(logger::SimpleLogger, level::CustomLevel, message, _module, group, id, filepath, line; kwargs...) =
    handle_message_custom(logger, level, message, _module, group, id, filepath, line; kwargs...)

handle_message_custom() is mostly a copy and paste of Base.corelogging.handle_message, with one line change:

levelstr = level == Warn ? "Warning" : string(level)
changed to
levelstr = level.name

1 Like