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
|
module Kemal
|
||||||
# Kemal::CommonLogHandler uses STDOUT by default and handles the logging of request/response process time.
|
# Kemal::CommonLogHandler uses STDOUT by default and handles the logging of request/response process time.
|
||||||
class CommonLogHandler < Kemal::BaseLogHandler
|
class CommonLogHandler < Kemal::BaseLogHandler
|
||||||
@handler : IO
|
@io : IO
|
||||||
|
|
||||||
def initialize(io : IO = STDOUT)
|
def initialize(@io : IO = STDOUT)
|
||||||
@handler = io
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def call(context : HTTP::Server::Context)
|
def call(context : HTTP::Server::Context)
|
||||||
time = Time.now
|
time = Time.now
|
||||||
call_next(context)
|
call_next(context)
|
||||||
elapsed_text = elapsed_text(Time.now - time)
|
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
|
context
|
||||||
end
|
end
|
||||||
|
|
||||||
def write(message : String)
|
def write(message : String)
|
||||||
@handler << message
|
@io << message
|
||||||
end
|
end
|
||||||
|
|
||||||
private def elapsed_text(elapsed)
|
private def elapsed_text(elapsed)
|
||||||
|
|
Loading…
Reference in a new issue