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

Allow IO/logger/proc as debugging configuration for all clients #8

Open
drnic opened this issue Apr 26, 2024 · 0 comments
Open

Allow IO/logger/proc as debugging configuration for all clients #8

drnic opened this issue Apr 26, 2024 · 0 comments

Comments

@drnic
Copy link
Owner

drnic commented Apr 26, 2024

Currently to enable faraday logging to STDOUT, each Groq::Client needs a setup like:

    logger = Logger.new($stdout)
    logger.level = Logger::DEBUG

    @client = Groq::Client.new do |faraday|
      # Log request and response bodies
      faraday.response :logger, logger, bodies: true
    end

Perhaps we can have configuration for this, which provides a corresponding Groq::Client.new(&block).

Perhaps allow:

  • an IO:

    Groq.configuration do |c|
      c.logger = $stdout
  • a Logger:

    logger = Logger.new($stdout)
    logger.level = Logger::DEBUG
    
    Groq.configuration do |c|
      c.logger = logger
  • or a &faraday_middleware proc

    logger = Logger.new($stdout)
    logger.level = Logger::DEBUG
    faraday_middleware = proc do |faraday|
      # Log request and response bodies
      faraday.response :logger, logger, bodies: true
    end
    
    Groq.configuration do |c|
      c.faraday_middleware = faraday_middleware

These examples would all produce the same Proc that's provided to all Groq::Client instances.

If a Groq::Client.new(&block) was explictly provided, then a warning would be posted that the logger or faraday_middleware configuration is being ignored.

@drnic drnic changed the title Allow logger as configuration for all clients Allow IO/logger/proc as debugging configuration for all clients Apr 26, 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

No branches or pull requests

1 participant