dblock / iex-ruby-client

IEX Finance API Ruby Client
MIT License
118 stars 60 forks source link

Enable Faraday logger configuration #87

Closed agrberg closed 3 years ago

agrberg commented 3 years ago

Enable passing of logger configuration hash to Faraday for finer logger control.

[closes #86]

dblock commented 3 years ago

This is good, i merged it.

I was wondering whether it would be valuable to write something like this:

IEX::Api::Client.configure do |config|
  config.logger.instance = Logger.new(STDOUT)
  config.logger.options = { bodies: true }
  config.logger.proc = proc { ... }
end

or

IEX::Api::Client.configure do |config|
  config.logger do |logger|
    logger.instance = Logger.new(STDOUT)
    logger.options = { bodies: true }
    logger.proc = proc { ... }
  end
end

If you're bored make a LoggerConfig class that behaves like Config, and it should allow this kind of behavior, avoiding having to do the whole is_a?(Hash) in the implementation, too.

agrberg commented 3 years ago

Popped that in https://github.com/dblock/iex-ruby-client/pull/88. Let me know what you think 👍