Skip to content

Commit

Permalink
Merge branch 'master' into open_telemetry
Browse files Browse the repository at this point in the history
  • Loading branch information
reidmorrison committed Dec 20, 2024
2 parents 6c912dd + 05a00e1 commit c4d12aa
Show file tree
Hide file tree
Showing 8 changed files with 61 additions and 6 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@ This project adheres to [Semantic Versioning](http://semver.org/).

## [unreleased]

- Correct `source_code_uri` URL

## [4.16.1]

- Add Honeybadger and Honeybadger Insights to Appenders doc.
- Fix regression in `SemanticLogger::Appenders#close`

## [4.16.0]

- Add appender for Honeybadger Insights using the events API
Expand Down
18 changes: 18 additions & 0 deletions docs/appenders.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ Log messages can be written to one or more of the following destinations at the
* MongoDB
* Rollbar
* Sentry
* Honeybadger
* Honeybadger Insights
* Logger, log4r, etc.

To ensure no log messages are lost it is recommend to use TCP over UDP for logging purposes.
Expand Down Expand Up @@ -739,6 +741,22 @@ SemanticLogger.tagged(transaction_name: "foo", user_id: 42, baz: "quz") do
end
~~~

### Honeybadger and Honeybadger Insights

Forward errors to Honeybadger.

~~~ruby
SemanticLogger.add_appender(appender: :honeybadger)
~~~

Forward all log messages to Honeybadger Insights as events.

~~~ruby
SemanticLogger.add_appender(appender: :honeybadger_insights)
~~~

Both appenders use the Honeybadger [gem configuration](https://docs.honeybadger.io/lib/ruby/gem-reference/configuration/).

### Logger, log4r, etc.

Semantic Logger can log to other logging libraries:
Expand Down
6 changes: 3 additions & 3 deletions docs/rails.md
Original file line number Diff line number Diff line change
Expand Up @@ -252,9 +252,9 @@ To show the Action View rendering messages in production:
config.rails_semantic_logger.rendered = true
~~~

#### Awesome Print Options
#### Amazing Print Options

The default Awesome Print options can be changed by supplying any valid Awesome Print options:
The default Amazing Print options can be changed by supplying any valid Amazing Print options:

~~~ruby
config.rails_semantic_logger.ap_options = {multiline: false}
Expand All @@ -266,7 +266,7 @@ See the [Amazing Print Documentation](https://github.com/amazing-print/amazing_p
Notes:

* The option `:multiline` is set to false if not supplied.
* Has no effect if Awesome Print is not installed.
* Has no effect if Amazing Print is not installed.

### Additional appenders

Expand Down
19 changes: 19 additions & 0 deletions docs/testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,25 @@ assert_semantic_logger_event(
)
~~~

### RSpec

For RSpec users, this sample supplied by @jgascoignetaylor-godaddy will be useful:
~~~ruby
context 'when it blows up' do
let(:capture_logger) { SemanticLogger::Test::CaptureLogEvents.new }

it 'should should log the error' do
allow_any_instance_of(MyThing).to receive(:logger).and_return(capture_logger)
MyThing.new('asdf').do_something!

expect(capture_logger.events.last.message).to include('Here is a message')
expect(capture_logger.events.last.level).to eq(:error)
end
end
~~~

Open to pull requests to implement the RSpec equivalent of the Minitest helpers: `SemanticLogger::Test::Minitest`.

### Other testing frameworks

If you use another testing framework and would like to contribute helper methods similar
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
2 changes: 1 addition & 1 deletion lib/semantic_logger/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module SemanticLogger
VERSION = "4.16.0".freeze
VERSION = "4.16.1".freeze
end
2 changes: 1 addition & 1 deletion semantic_logger.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Gem::Specification.new do |s|
s.metadata = {
"bug_tracker_uri" => "https://github.com/reidmorrison/semantic_logger/issues",
"documentation_uri" => "https://logger.rocketjob.io",
"source_code_uri" => "https://github.com/reidmorrison/semantic_logger/tree/#{SemanticLogger::VERSION}",
"source_code_uri" => "https://github.com/reidmorrison/semantic_logger/tree/v#{SemanticLogger::VERSION}",
"rubygems_mfa_required" => "true"
}
end
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 c4d12aa

Please sign in to comment.