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

support nil logger and ActiveSupport::Logger not Logger #175

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

dorianmariecom
Copy link

FIxes #168

@dorianmariecom dorianmariecom force-pushed the dorian/handle-nil-logger-and-active-support-logger branch from f09121d to e366eca Compare March 11, 2024 04:05
ensure
ActiveRecord::Base.logger = previous_logger
terminate_process(pid) if pid && process_exists?(pid)
end
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unrelated test coverage?

Copy link
Author

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 }
Copy link

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 ?

Copy link
Author

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

Copy link

@nbulaj nbulaj Mar 22, 2024

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

@rosa rosa mentioned this pull request Apr 30, 2024
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.

undefined method `silence' for nil (NoMethodError) with latest rails main
3 participants