Created logger
This commit is contained in:
parent
3c4619e040
commit
be58e009af
|
@ -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
|
|
@ -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
|
Loading…
Reference in New Issue