From 478601f3bd2cc8cd18ddf62de915474a87d79003 Mon Sep 17 00:00:00 2001 From: ederag Date: Wed, 31 Mar 2021 10:02:07 +0200 Subject: [PATCH] wrap trace in with_logger() --- src/util.jl | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/util.jl b/src/util.jl index 043f8ff..cff8593 100644 --- a/src/util.jl +++ b/src/util.jl @@ -9,12 +9,13 @@ for level in [:trace, :debug, :info, :warn, :error, :fatal] # NOTE: `@placeholder` in order to avoid hard-coding @__LINE__ etc macrocall.args[1] = Symbol($"@$level") quote - old_logger = global_logger() - global_logger(Logging.ConsoleLogger(Core.stderr, Logging.min_enabled_level(old_logger))) - ret = $(esc(macrocall)) - global_logger(old_logger) + global_min_level = Logging.min_enabled_level(global_logger()) + raw_logger = Logging.ConsoleLogger(Core.stderr, global_min_level) + Logging.with_logger(raw_logger) do + global ret = $(esc(macrocall)) + end ret end end end -end \ No newline at end of file +end