Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/ruby_llm/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def defaults = @defaults ||= {}
option :http_proxy, nil

option :logger, nil
option :log_file, -> { $stdout }
option :log_file, -> { ENV['RUBYLLM_LOG_FILE'] || $stdout }
option :log_level, -> { ENV['RUBYLLM_DEBUG'] ? Logger::DEBUG : Logger::INFO }
option :log_stream_debug, -> { ENV['RUBYLLM_STREAM_DEBUG'] == 'true' }
option :log_regexp_timeout, -> { Regexp.respond_to?(:timeout) ? (Regexp.timeout || 1.0) : nil }
Expand Down
18 changes: 18 additions & 0 deletions spec/ruby_llm_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,23 @@
expect(described_class.logger).to eq(logger)
end
end

context 'with RUBYLLM_LOG_FILE set' do
around do |example|
original_log_file = ENV.fetch('RUBYLLM_LOG_FILE', nil)
ENV['RUBYLLM_LOG_FILE'] = '/tmp/ruby_llm.log'
example.run
ensure
ENV['RUBYLLM_LOG_FILE'] = original_log_file
end

it 'uses the env var as the default log file' do
allow(Logger).to receive(:new)
.with('/tmp/ruby_llm.log', progname: 'RubyLLM', level: Logger::INFO)
.and_return(logger)

expect(described_class.logger).to eq(logger)
end
end
end
end