Skip to content

Commit

Permalink
wrap trace in with_logger()
Browse files Browse the repository at this point in the history
Co-Authored-by:  Chris Foster <[email protected]>
  • Loading branch information
ederag and c42f committed Mar 31, 2021
1 parent 6d118cf commit 24e4daa
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/util.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
end

0 comments on commit 24e4daa

Please sign in to comment.