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

fix: Use correct varname for closed appenders #290

Merged
merged 1 commit into from
Sep 3, 2024
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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ This project adheres to [Semantic Versioning](http://semver.org/).

## [unreleased]

- Fix regression in `SemanticLogger::Appenders#close`

## [4.16.0]

- Add appender for Honeybadger Insights using the events API
Expand Down
2 changes: 1 addition & 1 deletion lib/semantic_logger/appenders.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ def close
closed_appenders = []
each do |appender|
logger.trace "Closing appender: #{appender.name}"
appenders << appender
appender.flush
appender.close
closed_appenders << appender
rescue Exception => e
logger.error "Failed to close appender: #{appender.name}", e
end
Expand Down
11 changes: 11 additions & 0 deletions test/appenders_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -100,5 +100,16 @@ class AppendersTest < Minitest::Test
# assert_instance_of SemanticLogger::Appender::Async, appender
# end
end

describe "#close" do
it "closes appenders" do
appender = appenders.add(file_name: "test.log")

appenders.close

assert_equal 0, capture_logger.events.count { |it| it.message.match?(/failed/i) }
assert_equal 0, appenders.size
end
end
end
end
Loading