mirror of
https://gitea.invidious.io/iv-org/shard-kemal.git
synced 2024-08-15 00:53:36 +00:00
Add flush on newline Fixes #15
This commit is contained in:
parent
173bbf7639
commit
9cb3cafa62
2 changed files with 5 additions and 4 deletions
|
@ -18,8 +18,7 @@ describe "Logger" do
|
||||||
logger = Kemal::Logger.new
|
logger = Kemal::Logger.new
|
||||||
logger.handler.should be_a File
|
logger.handler.should be_a File
|
||||||
end
|
end
|
||||||
|
|
||||||
#TODO: Check https://github.com/manastech/crystal/issues/1899
|
|
||||||
it "writes to a file in production" do
|
it "writes to a file in production" do
|
||||||
config = Kemal.config
|
config = Kemal.config
|
||||||
config.env = "production"
|
config.env = "production"
|
||||||
|
@ -28,6 +27,6 @@ describe "Logger" do
|
||||||
logger.call request
|
logger.call request
|
||||||
str = File.read("kemal.log")
|
str = File.read("kemal.log")
|
||||||
File.delete("kemal.log")
|
File.delete("kemal.log")
|
||||||
str.includes?("GET /?message=world&time=now").should eq false
|
str.includes?("GET /?message=world&time=now").should eq true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -4,7 +4,9 @@ class Kemal::Logger < HTTP::Handler
|
||||||
def initialize
|
def initialize
|
||||||
@env = Kemal.config.env
|
@env = Kemal.config.env
|
||||||
@handler = if @env == "production"
|
@handler = if @env == "production"
|
||||||
File.new("kemal.log", "a")
|
handler = File.new("kemal.log", "a")
|
||||||
|
handler.flush_on_newline = true
|
||||||
|
handler
|
||||||
else
|
else
|
||||||
STDOUT
|
STDOUT
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue