-
-
Notifications
You must be signed in to change notification settings - Fork 277
Adding option for configuring custom log Regexp timeout #364
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
base: main
Are you sure you want to change the base?
Changes from all commits
e271c0f
42434b9
287b094
cd10d58
838ad40
3706ce1
dbae501
25d24b3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,7 +43,8 @@ class Configuration | |
:logger, | ||
:log_file, | ||
:log_level, | ||
:log_stream_debug | ||
:log_stream_debug, | ||
:log_regexp_timeout | ||
|
||
def initialize | ||
@request_timeout = 120 | ||
|
@@ -64,6 +65,7 @@ def initialize | |
@log_file = $stdout | ||
@log_level = ENV['RUBYLLM_DEBUG'] ? Logger::DEBUG : Logger::INFO | ||
@log_stream_debug = ENV['RUBYLLM_STREAM_DEBUG'] == 'true' | ||
@log_regexp_timeout = Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('3.2.0') ? (Regexp.timeout || 1.0) : nil | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I noticed that in Do you have any thoughts or preferences on whether we should enforce a fallback, or keep respecting There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Convention over configuration! 1 second is perfect. |
||
end | ||
|
||
def instance_variables | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -66,8 +66,19 @@ def setup_logging(faraday) | |
errors: true, | ||
headers: false, | ||
log_level: :debug do |logger| | ||
logger.filter(%r{[A-Za-z0-9+/=]{100,}}, 'data":"[BASE64 DATA]"') | ||
logger.filter(/[-\d.e,\s]{100,}/, '[EMBEDDINGS ARRAY]') | ||
if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('3.2.0') | ||
logger.filter( | ||
Regexp.new('[A-Za-z0-9+/=]{100,}', timeout: @config.log_regexp_timeout), | ||
'data":"[BASE64 DATA]"' | ||
) | ||
logger.filter(Regexp.new('[-\\d.e,\\s]{100,}', timeout: @config.log_regexp_timeout), '[EMBEDDINGS ARRAY]') | ||
else | ||
if @config.log_regexp_timeout | ||
RubyLLM.logger.warn("log_regexp_timeout is not supported on Ruby #{RUBY_VERSION}") | ||
end | ||
logger.filter(Regexp.new('[A-Za-z0-9+/=]{100,}'), 'data":"[BASE64 DATA]"') | ||
logger.filter(Regexp.new('[-\\d.e,\\s]{100,}'), '[EMBEDDINGS ARRAY]') | ||
end | ||
Comment on lines
+69
to
+81
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we should simplify all that and use the same approach as Rails: https://github.com/rails/rails/pull/53490/files There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think I fully follow. logger.filter(
Regexp.new('[A-Za-z0-9+/=]{100,}', timeout: @config.log_regexp_timeout),
'data":"[BASE64 DATA]"'
)
logger.filter(Regexp.new('[-\\d.e,\\s]{100,}', timeout: @config.log_regexp_timeout), '[EMBEDDINGS ARRAY]') If you are proposing to use global |
||
end | ||
end | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would not categorise this as basic logging. Let's remove that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
May be worth having a separate section called "Advanced logging options" where to put also the logger and log file options. Since that requires a rewrite of the section, I'm willing to take that on myself.