@@ -27,10 +27,11 @@ mutable struct TestLogger <: AbstractLogger
2727 catch_exceptions:: Bool
2828 shouldlog_args
2929 message_limits:: Dict{Any,Int}
30+ respect_maxlog:: Bool
3031end
3132
32- TestLogger (; min_level= Info, catch_exceptions= false ) =
33- TestLogger (LogRecord[], min_level, catch_exceptions, nothing , Dict {Any, Int} ())
33+ TestLogger (; min_level= Info, catch_exceptions= false , respect_maxlog = true ) =
34+ TestLogger (LogRecord[], min_level, catch_exceptions, nothing , Dict {Any, Int} (), respect_maxlog )
3435Logging. min_enabled_level (logger:: TestLogger ) = logger. min_level
3536
3637function Logging. shouldlog (logger:: TestLogger , level, _module, group, id)
4546function Logging. handle_message (logger:: TestLogger , level, msg, _module,
4647 group, id, file, line; kwargs... )
4748 @nospecialize
48- maxlog = get (kwargs, :maxlog , nothing )
49- if maxlog isa Core. BuiltinInts
50- remaining = get! (logger. message_limits, id, Int (maxlog):: Int )
51- logger. message_limits[id] = remaining - 1
52- remaining > 0 || return
49+ if logger. respect_maxlog
50+ maxlog = get (kwargs, :maxlog , nothing )
51+ if maxlog isa Core. BuiltinInts
52+ remaining = get! (logger. message_limits, id, Int (maxlog):: Int )
53+ logger. message_limits[id] = remaining - 1
54+ remaining > 0 || return
55+ end
5356 end
5457 push! (logger. logs, LogRecord (level, msg, _module, group, id, file, line, kwargs))
5558end
0 commit comments