Skip to content

Commit

Permalink
Merge pull request #99 from invenia/rf/stacktrace-fix
Browse files Browse the repository at this point in the history
Fixed broken stacktrace behaviour
  • Loading branch information
rofinn authored Aug 9, 2018
2 parents 441189d + 627b5d0 commit f491d13
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/loggers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -333,13 +333,13 @@ method with a `@sync` in order to synchronize all handler tasks.
* `args::Dict`: a dict of msg fields and values that should be passed to `logger.record`.
"""
function log(logger::Logger, rec::Record)
@sync for l in reverse!(getpath(logger))
for l in reverse!(getpath(logger))
# If none of the `Filter`s return false we're good to log our record.
!all(f -> f(rec), getfilters(l)) && break

# Log to all of our handlers
for (name, handler) in l.handlers
@async log(handler, rec)
log(handler, rec)
end

# Break if this is the root logger or it's non-propagating
Expand Down
30 changes: 30 additions & 0 deletions test/loggers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -202,4 +202,34 @@
Memento.config("notice"; recursive=true)
@test all(l -> getlevel(l) == "notice", values(Memento._loggers))
end

@testset "Stacktraces" begin
io = IOBuffer()

try
handler = DefaultHandler(
io,
DefaultFormatter(string(FMT_STR, " | {stacktrace}"))
)

logger = Logger(
"Logger.example",
Dict("Buffer" => handler),
"info",
LEVELS,
DefaultRecord,
true
)

# Define a test function that logs a message
test_func() = info(logger, "Hello")
test_func()

msg = String(take!(io))
@test !isempty(msg)
@test occursin("test_func", msg)
finally
close(io)
end
end
end

0 comments on commit f491d13

Please sign in to comment.