@@ -71,6 +71,15 @@ logger type.
71
71
catch_exceptions (logger) = true
72
72
73
73
74
+ # Prevent invalidation when packages define custom loggers
75
+ # Using invoke in combination with @nospecialize eliminates backedges to these methods
76
+ function _invoked_shouldlog (logger, level, _module, group, id)
77
+ @nospecialize
78
+ invoke (shouldlog, Tuple{typeof (logger), typeof (level), typeof (_module), typeof (group), typeof (id)}, logger, level, _module, group, id)
79
+ end
80
+
81
+ _invoked_min_enabled_level (@nospecialize (logger)) = invoke (min_enabled_level, Tuple{typeof (logger)}, logger)
82
+
74
83
75
84
"""
76
85
NullLogger()
@@ -315,7 +324,7 @@ function logmsg_code(_module, file, line, level, message, exs...)
315
324
id = $ id
316
325
# Second chance at an early bail-out (before computing the message),
317
326
# based on arbitrary logger-specific logic.
318
- if shouldlog (logger, level, _module, group, id)
327
+ if _invoked_shouldlog (logger, level, _module, group, id)
319
328
file = $ file
320
329
line = $ line
321
330
try
@@ -374,7 +383,7 @@ struct LogState
374
383
logger:: AbstractLogger
375
384
end
376
385
377
- LogState (logger) = LogState (LogLevel (min_enabled_level (logger)), logger)
386
+ LogState (logger) = LogState (LogLevel (_invoked_min_enabled_level (logger)), logger)
378
387
379
388
function current_logstate ()
380
389
logstate = current_task (). logstate
0 commit comments