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

{config,loggable}: set default Logger level to Logger::WARN #551

Merged
merged 1 commit into from
Feb 10, 2020
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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ Airbrake Ruby Changelog
```
ERROR -- : **Airbrake: tdigest.count=94, but count=100
```
* Fixed `Airbrake::Loggable` and `Airbrake::Config.instance.logger` not being
set to `Logger::WARN` by default (as promised by the README)
([#551](https://github.com/airbrake/airbrake-ruby/pull/551))

### [v4.13.0][v4.13.0] (January 27, 2020)

Expand Down
4 changes: 3 additions & 1 deletion lib/airbrake-ruby/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -119,12 +119,13 @@ def instance

# @param [Hash{Symbol=>Object}] user_config the hash to be used to build the
# config
# rubocop:disable Metrics/AbcSize
def initialize(user_config = {})
self.proxy = {}
self.queue_size = 100
self.workers = 1
self.code_hunks = true
self.logger = ::Logger.new(File::NULL)
self.logger = ::Logger.new(File::NULL).tap { |l| l.level = Logger::WARN }
self.project_id = user_config[:project_id]
self.project_key = user_config[:project_key]
self.host = 'https://api.airbrake.io'
Expand All @@ -149,6 +150,7 @@ def initialize(user_config = {})

merge(user_config)
end
# rubocop:enable Metrics/AbcSize

# The full URL to the Airbrake Notice API. Based on the +:host+ option.
# @return [URI] the endpoint address
Expand Down
2 changes: 1 addition & 1 deletion lib/airbrake-ruby/loggable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class << self

# @return [Logger]
def instance
@instance ||= ::Logger.new(File::NULL)
@instance ||= ::Logger.new(File::NULL).tap { |l| l.level = ::Logger::WARN }
end
end

Expand Down
6 changes: 6 additions & 0 deletions spec/config_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -163,4 +163,10 @@
end
end
end

describe "#logger" do
it "sets logger level to Logger::WARN" do
expect(subject.logger.level).to eq(Logger::WARN)
end
end
end
17 changes: 17 additions & 0 deletions spec/loggable_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
RSpec.describe Airbrake::Loggable do
describe ".instance" do
it "returns a logger" do
expect(described_class.instance).to be_a(Logger)
end
end

describe "#logger" do
let(:subject) do
Class.new { include Airbrake::Loggable }.new
end

it "returns a logger that has Logger::WARN severity" do
expect(subject.logger.level).to eq(Logger::WARN)
end
end
end