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

Log: delete source from builder cache when finalize #14475

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
6 changes: 6 additions & 0 deletions src/log/builder.cr
Original file line number Diff line number Diff line change
Expand Up @@ -157,4 +157,10 @@ class Log::Builder
end
false
end

# NOTE: workaround for https://github.com/crystal-lang/crystal/pull/14473
protected def cleanup_collected_log(log : Log) : Nil
ref = @logs.fetch(log.source) { return }
@logs.delete(log.source) if ref.value.nil? || ref.value == log
end
end
5 changes: 5 additions & 0 deletions src/log/log.cr
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ class Log
@initial_level = level
end

def finalize : Nil
# NOTE: workaround for https://github.com/crystal-lang/crystal/pull/14473
Log.builder.cleanup_collected_log(self)
end

# :nodoc:
def changed_level : Severity?
@level
Expand Down
Loading