Skip to content

Commit

Permalink
Merge pull request #290 from ixti/fix-appenders-close
Browse files Browse the repository at this point in the history
  • Loading branch information
reidmorrison authored Sep 3, 2024
2 parents 364f3b9 + ce574f8 commit f2558aa
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
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

0 comments on commit f2558aa

Please sign in to comment.