OpenAI: log errors#614
Conversation
|
Removing connection = Faraday.new do |f|
f.options[:timeout] = @request_timeout
f.request(:multipart) if multipart
f.use MiddlewareErrors if @log_errors
# f.response :raise_error
f.response :json
endNot sure why they chose to hide log output from errors. |
| @translator ||= | ||
| if @i18n_tasks.translation_config[:openai_log_errors] | ||
| OpenAI::Client.new(access_token: api_key, log_errors: @i18n_tasks.translation_config[:openai_log_errors]) do |f| | ||
| f.response :logger, Logger.new($stdout), bodies: true |
There was a problem hiding this comment.
- Errors should be logged to
STDERR - I think we can always log the errors, no need for the environment variable
|
Differents repository are recommanding to set this option only to true for development, as it can leak leak private data to your logs. |
| access_token: api_key, | ||
| # Highly recommended in development, so you can see what errors OpenAI is returning. | ||
| # Not recommended in production because it could leak private data to your logs. | ||
| log_errors: ENV.fetch('RAILS_ENV', ENV.fetch('RACK_ENV', '')) == 'development' |
There was a problem hiding this comment.
RAILS_ENV and RACK_ENV are usually not defined when running i18n-tasks.
While it supports Rails, it does it entirely via static analysis, and does not load rails itself.
It is possible of course to load i18n-tasks as a library from within rails, in which case it'd be good to respect this.
However, most of the time, this string will be empty. So let's also log errors when it's empty.
There was a problem hiding this comment.
Ok i see. Anyways, in your README.md most of the time the gem will be installed only in the group :development anyways.
In order to have more detailed informations you can pass now OPENAI_LOG_ERRORS as environment variable to display more informations.