Created logger

This commit is contained in:
Sdogruyol 2015-10-27 21:01:36 +02:00
parent 3c4619e040
commit be58e009af
2 changed files with 24 additions and 0 deletions

13
spec/logger_spec.cr Normal file
View file

@ -0,0 +1,13 @@
require "./spec_helper"
describe "Logger" do
it "logs stuff" do
IO.pipe do |r,w|
logger = Kemal::Logger.new(w)
logger.info "Info from logger"
r.gets.should match(/Info from logger/)
end
end
end

11
src/kemal/logger.cr Normal file
View file

@ -0,0 +1,11 @@
class Kemal::Logger
LOG_LEVELS = %w(info debug error warn)
def initialize(@stream)
end
{% for method in LOG_LEVELS %}
def {{method.id}}(message)
@stream.puts message
end
{% end %}
end