lostisland / faraday

Simple, but flexible HTTP client library, with support for multiple backends.
https://lostisland.github.io/faraday
MIT License
5.75k stars 978 forks source link

Suppressing logs #505

Closed migu0 closed 9 years ago

migu0 commented 9 years ago

I'm using a gem closeio, which loads another gem faraday as a dependency. For each request I make through the closeio gem, Faraday produces lots of logs that I would like to suppress.

11:40:38 clock.1  | I, [2015-06-15T11:40:38.934015 #64794]  INFO -- : Enqueued CloseIoUpdateCustomerJob (Job ID: beca8405-adcb-4c88-a43c-82ba3cb4b455) to Sidekiq(default) with arguments: gid://rails-devise-roles/Customer/67
11:40:38 worker.1 | I, [2015-06-15T11:40:38.935280 #64793]  INFO -- Status: 200
11:40:38 worker.1 | D, [2015-06-15T11:40:38.935360 #64793] DEBUG -- response: content-type: "application/json"
11:40:38 worker.1 | date: "Mon, 15 Jun 2015 01:40:38 GMT"
11:40:38 worker.1 | server: "ElasticWWW"
11:40:38 worker.1 | set-cookie: "session=; Expires=Thu, 01-Jan-1970 00:00:00 GMT; Max-Age=0; Path=/"
11:40:38 worker.1 | strict-transport-security: "max-age=31536000; includeSubDomains"
11:40:38 worker.1 | vary: "Accept"
11:40:38 worker.1 | x-frame-options: "SAMEORIGIN"
11:40:38 worker.1 | content-length: "720"
11:40:38 worker.1 | connection: "Close"

I have tried the following in config/initializers/sidekiq.rb without success:

Sidekiq.configure_server do |config|
  config.logger.level = Logger::WARN
end

How can I suppress these logs?

zorbash commented 9 years ago

Care to provide some context on how you're initializing the closeio client?

Since closeio tries to assign a logger by looking up logger @see closeio/client.rb#L71 you could have it assign Logger.new(File::NULL) as the logger.

I think this issue can be closed, as it's more specific to your application code than the gem itself.

migu0 commented 9 years ago

Thanks so much for your help, you solved a big problem for us. I wasn't aware of that option in the closeio client and changed it to disable the logger like so:

Closeio::Client.new(ENV['CLOSEIO_API_KEY'], false)
# removed code: Closeio::Client.new(ENV['CLOSEIO_API_KEY'])