Skip to content

Duplicate Rails.logger before assigning it to the SDK#2086

Merged
st0012 merged 2 commits intomasterfrom
duplicate-logger
Aug 9, 2023
Merged

Duplicate Rails.logger before assigning it to the SDK#2086
st0012 merged 2 commits intomasterfrom
duplicate-logger

Conversation

@st0012
Copy link
Copy Markdown
Contributor

@st0012 st0012 commented Aug 6, 2023

I discovered this while investigating #2031: If we don't duplicate Rails.logger, configurations made to the SDK's logger will be applied to the Rails logger as well.

For example, in an Rails app:

Sentry.init do |config|
  config.logger.level = Logger::WARN
end

Will make the Rails logger's level to be Logger::WARN too. I think most users wouldn't expect this and will find it confusing.

If we don't duplicate it, logger configuration made to the SDK's logger
will be applied to the Rails logger as well.

For example, in an Rails app:

```rb
Sentry.init do |config|
  config.logger.level = Logger::WARN
end
```

Will make the Rails logger's level to be `Logger::WARN` as well.
@st0012 st0012 added the bug fix label Aug 6, 2023
@st0012 st0012 added this to the 5.11.0 milestone Aug 6, 2023
@codecov
Copy link
Copy Markdown

codecov bot commented Aug 6, 2023

Codecov Report

Patch coverage: 100.00% and no project coverage change.

Comparison is base (bc0f8ce) 83.23% compared to head (b286e98) 83.23%.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #2086   +/-   ##
=======================================
  Coverage   83.23%   83.23%           
=======================================
  Files         119      119           
  Lines        5671     5674    +3     
=======================================
+ Hits         4720     4723    +3     
  Misses        951      951           
Files Changed Coverage Δ
sentry-rails/lib/sentry/rails/configuration.rb 100.00% <100.00%> (ø)
sentry-rails/spec/dummy/test_rails_app/app.rb 92.64% <100.00%> (ø)
sentry-rails/spec/sentry/rails_spec.rb 96.19% <100.00%> (+0.06%) ⬆️

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@st0012 st0012 mentioned this pull request Aug 6, 2023
@st0012 st0012 requested a review from sl0thentr0py August 6, 2023 17:35
@st0012 st0012 merged commit 8abb2d2 into master Aug 9, 2023
@st0012 st0012 deleted the duplicate-logger branch August 9, 2023 14:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants