-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Use Strftime to improve fixed timestamp performance #1796
Conversation
76d1422
to
80e45ea
Compare
@mururu Could you also check this? |
|
||
config_param :output_type, :string, default: 'json' | ||
|
||
def configure(conf) | ||
super | ||
|
||
@time_formatter = Strftime.new(TIME_FORMAT) |
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.
Don't we need rescue nil
here?
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.
Yes because TIME_FORMAT is fixed.
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 see.
lib/fluent/log.rb
Outdated
@formatter = Proc.new { |type, time, level, msg| | ||
r = { | ||
'time' => time.strftime(@time_format), | ||
'time' => @time_formatter ? @time_formatter.exec(time) : time.strftime(@time_format), |
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.
How about defining method for @time_formatter ? @time_formatter.exec(time) : time.strftime(@time_format)
?
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.
Done.
Looks good. |
Use
Strftime
instead ofTime#strftime
improves the performance of time formatting.