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

Disable logging in Rails testing #727

Closed
marclennox opened this issue Jul 27, 2022 · 7 comments · Fixed by #729
Closed

Disable logging in Rails testing #727

marclennox opened this issue Jul 27, 2022 · 7 comments · Fixed by #729

Comments

@marclennox
Copy link
Contributor

I'm getting a lot of log messages when running Rails specs from this gem. Is there a way to disable these logs in testing? The only solution I found was to change from the Sidekiq logger to the Rails logger, but in your documentation you don't recommend changing this configuration.

@mhenrixon
Copy link
Owner

My recommendation was more for production environment.

It is common to disable logging for test environment which is totally fine.

Perhaps you can configure logging based on which rails environment it is?

@marclennox
Copy link
Contributor Author

Cool thanks. Is there a way to disable logging entirely with this gem?

@mhenrixon
Copy link
Owner

mhenrixon commented Jul 27, 2022

From the top of my head: no. It seems like a very nice feature to have.

Perhaps something like:

SidekiqUniqueJobs.configure do |config|
  config.logger.level = :fatal
end

@marclennox
Copy link
Contributor Author

That would work, or alternatively

config.logger = nil

@marclennox
Copy link
Contributor Author

config.logger = Rails.env.test? ? nil : Sidekiq.logger

@mhenrixon
Copy link
Owner

I'm not even sure it works without a logger, try it first. Otherwise

config.logger = Rails.env.test? ? Logger.new(nil) : Sidekiq.logger

Should do the trick, I'll see if I can add a way to just silence logging also.

@marclennox
Copy link
Contributor Author

Perfect, thanks

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 a pull request may close this issue.

2 participants