Skip to content

Commit

Permalink
Event limit seems to work
Browse files Browse the repository at this point in the history
  • Loading branch information
ashton314 committed Jun 2, 2023
1 parent cb43702 commit 8028690
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/TrackedFloat.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ abstract type AbstractTrackedFloat <: AbstractFloat end
if isa(ft_config.log.maxLogs, Int) && ft_config.log.maxLogs > 0
ft_config.log.maxLogs -= 1
log_event(event(string(fn), collect(args), result, injected))
else if isa(ft_config.log.maxLogs, Unbounded)
elseif isa(ft_config.log.maxLogs, Unbounded)
log_event(event(string(fn), collect(args), result, injected))
end
end
Expand Down
25 changes: 25 additions & 0 deletions test/logger_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,28 @@ f0(n) = f1((n * n - 4.0) / (n - 2.0))
# We get the ((check_error line) + (3 lines of context) + (blank line) = 5) * (6 events)
@test countlines(tmp2) == 5 * 6
end

@testset "maxLogs: only log n events then stop" begin
ft_init()
config_session(testing=true)
tmp1 = tempname() # This should automatically get cleaned up
tmp2 = tempname()

floaty = TrackedFloat32(2.0)

exclude_stacktrace([:kill,:inject])

config_logger(filename=tmp1, maxFrames=1, buffersize=1)
f0(floaty)
write_out_logs()

# We get the ((check_error line) + (1 lines of context) + (blank line) = 3) * (6 events)
@test countlines(tmp1) == 18

config_logger(filename=tmp2, maxLogs=3)
f0(floaty)
write_out_logs()

# We get the ((check_error line) + (1 lines of context) + (blank line) = 3) * (3 events)
@test countlines(tmp2) == 9
end

0 comments on commit 8028690

Please sign in to comment.