-
Notifications
You must be signed in to change notification settings - Fork 83
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
support nil logger and ActiveSupport::Logger not Logger #175
base: main
Are you sure you want to change the base?
support nil logger and ActiveSupport::Logger not Logger #175
Conversation
f09121d
to
e366eca
Compare
ensure | ||
ActiveRecord::Base.logger = previous_logger | ||
terminate_process(pid) if pid && process_exists?(pid) | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unrelated test coverage?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I had a hard time trying to reproduce the bug, I don't know the library very well, so happy for pointers for better ways to do it
@@ -10,7 +10,7 @@ module Poller | |||
|
|||
private | |||
def with_polling_volume | |||
if SolidQueue.silence_polling? | |||
if SolidQueue.silence_polling? && ActiveRecord::Base.logger | |||
ActiveRecord::Base.logger.silence { yield } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe better just use safe-navigation ActiveRecord::Base.logger&.silence
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then it will not yield
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But why? 🤔
irb(main):003> l = Logger.new(STDOUT)
irb(main):004> l.info { "OK" }
I, [2024-03-22T15:10:27.939697 #68513] INFO -- : OK
=> true
irb(main):005> l&.info { "OK" }
I, [2024-03-22T15:10:31.957994 #68513] INFO -- : OK
=> true
irb(main):008> n = nil
=> nil
irb(main):009> n&.info { "OK" }
=> nil
Or I'd better have to think an example with yield
, yes
FIxes #168