mirror of
https://gitea.invidious.io/iv-org/shard-kemal.git
synced 2024-08-15 00:53:36 +00:00
Optimize CommonLogHandler to directly use the handler instead of string interpolation
This commit is contained in:
parent
212ea8707d
commit
ae25d0a774
1 changed files with 3 additions and 11 deletions
|
@ -17,9 +17,9 @@ class Kemal::CommonLogHandler < Kemal::BaseLogHandler
|
|||
def call(context)
|
||||
time = Time.now
|
||||
call_next(context)
|
||||
elapsed = Time.now - time
|
||||
elapsed_text = elapsed_text(elapsed)
|
||||
write "#{time} #{context.response.status_code} #{context.request.method} #{context.request.resource} - #{elapsed_text}\n"
|
||||
elapsed_text = elapsed_text(Time.now - time)
|
||||
@handler << time << " " << context.response.status_code << " " << context.request.method << " " << context.request.resource << " " << elapsed_text << "\n"
|
||||
@handler.rewind
|
||||
context
|
||||
end
|
||||
|
||||
|
@ -35,12 +35,4 @@ class Kemal::CommonLogHandler < Kemal::BaseLogHandler
|
|||
|
||||
"#{(millis * 1000).round(2)}µs"
|
||||
end
|
||||
|
||||
def write(message)
|
||||
if @env == "production"
|
||||
@handler.write message.to_slice
|
||||
else
|
||||
@handler.print message
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue