Skip to content

Commit 478601f

Browse files
committed
wrap trace in with_logger()
1 parent 6d118cf commit 478601f

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/util.jl

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,13 @@ for level in [:trace, :debug, :info, :warn, :error, :fatal]
99
# NOTE: `@placeholder` in order to avoid hard-coding @__LINE__ etc
1010
macrocall.args[1] = Symbol($"@$level")
1111
quote
12-
old_logger = global_logger()
13-
global_logger(Logging.ConsoleLogger(Core.stderr, Logging.min_enabled_level(old_logger)))
14-
ret = $(esc(macrocall))
15-
global_logger(old_logger)
12+
global_min_level = Logging.min_enabled_level(global_logger())
13+
raw_logger = Logging.ConsoleLogger(Core.stderr, global_min_level)
14+
Logging.with_logger(raw_logger) do
15+
global ret = $(esc(macrocall))
16+
end
1617
ret
1718
end
1819
end
1920
end
20-
end
21+
end

0 commit comments

Comments
 (0)