mirror of
https://gitea.invidious.io/iv-org/shard-kemal.git
synced 2024-08-15 00:53:36 +00:00
Don't use handler as the IO name
This commit is contained in:
parent
677dc62832
commit
dfd127e1ed
1 changed files with 4 additions and 5 deletions
|
@ -1,22 +1,21 @@
|
|||
module Kemal
|
||||
# Kemal::CommonLogHandler uses STDOUT by default and handles the logging of request/response process time.
|
||||
class CommonLogHandler < Kemal::BaseLogHandler
|
||||
@handler : IO
|
||||
@io : IO
|
||||
|
||||
def initialize(io : IO = STDOUT)
|
||||
@handler = io
|
||||
def initialize(@io : IO = STDOUT)
|
||||
end
|
||||
|
||||
def call(context : HTTP::Server::Context)
|
||||
time = Time.now
|
||||
call_next(context)
|
||||
elapsed_text = elapsed_text(Time.now - time)
|
||||
@handler << time << " " << context.response.status_code << " " << context.request.method << " " << context.request.resource << " " << elapsed_text << "\n"
|
||||
@io << time << " " << context.response.status_code << " " << context.request.method << " " << context.request.resource << " " << elapsed_text << "\n"
|
||||
context
|
||||
end
|
||||
|
||||
def write(message : String)
|
||||
@handler << message
|
||||
@io << message
|
||||
end
|
||||
|
||||
private def elapsed_text(elapsed)
|
||||
|
|
Loading…
Reference in a new issue