Closed rofinn closed 4 years ago
Yep, turns out I can implement this in ~30 lines of code :)
julia> using Memento
[ Info: Precompiling Memento [f28f55f0-a522-5efc-85c2-fe41dfb9b2d9]
julia> l = getlogger()
Logger(root)
julia> push!(l, Memento.Escalator());
julia> info(l, "Hello World!")
[info | root]: Hello World!
julia> warn(l, "Hello World!")
ERROR: Memento.EscalationError("[warn | root]: Hello World!")
Stacktrace:
[1] emit(::Memento.Escalator{DefaultFormatter}, ::DefaultRecord) at /Users/rory/repos/invenia/Memento.jl/src/handlers.jl:257
[2] log(::Memento.Escalator{DefaultFormatter}, ::DefaultRecord) at /Users/rory/repos/invenia/Memento.jl/src/handlers.jl:44
[3] log(::Logger, ::DefaultRecord) at /Users/rory/repos/invenia/Memento.jl/src/loggers.jl:362
[4] _log(::Logger, ::String, ::String) at /Users/rory/repos/invenia/Memento.jl/src/loggers.jl:407
[5] log at /Users/rory/repos/invenia/Memento.jl/src/loggers.jl:386 [inlined]
[6] warn(::Logger, ::String) at /Users/rory/repos/invenia/Memento.jl/src/loggers.jl:422
[7] top-level scope at REPL[5]:1
Implement a special handler type which will escalate any logs over a certain threshold to errors. This is useful for testing if your goal is to avoid introducing any extra warning noise to a production system (e.g., run the system under normal conditions and ensure that it doesn't produce any warnings).