Start decoupling logger

This commit is contained in:
Sdogruyol 2016-02-11 23:26:47 +02:00
parent ffc3d6d224
commit 850af8819e
6 changed files with 15 additions and 12 deletions

View file

@ -28,4 +28,10 @@ describe "Config" do
config.add_handler CustomTestHandler.new
config.handlers.size.should eq(1)
end
it "sets a custom logger" do
config = Kemal::Config::INSTANCE
config.logger = CustomTestHandler.new
config.handlers.first.should be_a(CustomTestHandler)
end
end

View file

@ -2,27 +2,27 @@ require "./spec_helper"
describe "Kemal::LogHandler" do
it "creates a handler" do
logger = Kemal::LogHandler.new
logger = Kemal::LogHandler.new "production"
logger.handler.should_not be nil
end
it "creates a STDOUT handler by default" do
config = Kemal.config
logger = Kemal::LogHandler.new
logger = Kemal::LogHandler.new "production"
logger.handler.should be_a IO
end
it "creates a file handler in production" do
config = Kemal.config
config.env = "production"
logger = Kemal::LogHandler.new
logger = Kemal::LogHandler.new "production"
logger.handler.should be_a File
end
it "writes to a file in production" do
config = Kemal.config
config.env = "production"
logger = Kemal::LogHandler.new
logger = Kemal::LogHandler.new "production"
request = HTTP::Request.new("GET", "/?message=world&time=now")
io = MemoryIO.new
response = HTTP::Server::Response.new(io)