diff --git a/base/logging/logging.jl b/base/logging/logging.jl index 5cf3882a300ec..e0cc936bfbf3f 100644 --- a/base/logging/logging.jl +++ b/base/logging/logging.jl @@ -409,7 +409,7 @@ function logmsg_code(_module, file, line, level, message, exs...) end line = $(log_data._line) local msg, kwargs - $(logrecord) && invokelatest($handle_message, + $(logrecord) && $handle_message_nothrow( logger, level, msg, _module, group, id, file, line; kwargs...) end @@ -420,6 +420,17 @@ function logmsg_code(_module, file, line, level, message, exs...) end end +@noinline function handle_message_nothrow(logger, level, msg, _module, group, id, file, + line, args...; kwargs...) + try + @invokelatest handle_message( + logger, level, msg, _module, group, id, file, line, args...; + kwargs...) + catch err + @invokelatest logging_error(logger, level, _module, group, id, file, line, err, true) + end +end + function process_logmsg_exs(_orig_module, _file, _line, level, message, exs...) @nospecialize local _group, _id