Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed broken stacktrace behaviour #99

Merged
merged 1 commit into from
Aug 9, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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