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

Logger is not initialised by default in a Rails 6 environment #395

Open
molfar opened this issue Jun 20, 2019 · 2 comments
Open

Logger is not initialised by default in a Rails 6 environment #395

molfar opened this issue Jun 20, 2019 · 2 comments

Comments

@molfar
Copy link

molfar commented Jun 20, 2019

I set up sneakers with rails project. Everything following instructions. But have this error:

Unexpected error undefined method `debug' for nil:NilClass
Did you mean?  debugger
  /Users/molfar/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/sneakers-2.11.0/lib/sneakers/worker.rb:114:in `worker_trace'
  /Users/molfar/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/sneakers-2.11.0/lib/sneakers/worker.rb:103:in `run'
  /Users/molfar/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/sneakers-2.11.0/lib/sneakers/workergroup.rb:42:in `block in run'
  /Users/molfar/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/sneakers-2.11.0/lib/sneakers/workergroup.rb:41:in `each'
  /Users/molfar/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/sneakers-2.11.0/lib/sneakers/workergroup.rb:41:in `run'

I think its because

logger.debug(log_msg(msg))
does not check if logger exists.
It will be better that sneakers use rails logger or stdout by default, with no config.

@michaelklishin
Copy link
Collaborator

This project is not tied to Rails. We should make the logging method more defensive. You are welcome to contribute a PR.

@shime
Copy link

shime commented Sep 27, 2019

I've managed to work around this problem (with Rails 6.0.0) by explicitly setting the logger.

Sneakers.logger = Rails.logger
Sneakers::Worker.logger = Rails.logger

@michaelklishin michaelklishin changed the title Error with nil logger Logger is not initialised by default in a Rails 6 environment Sep 29, 2019
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

No branches or pull requests

3 participants