mirror of
https://gitea.invidious.io/iv-org/shard-kemal.git
synced 2024-08-15 00:53:36 +00:00
Created logger
This commit is contained in:
parent
3c4619e040
commit
be58e009af
2 changed files with 24 additions and 0 deletions
13
spec/logger_spec.cr
Normal file
13
spec/logger_spec.cr
Normal 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
11
src/kemal/logger.cr
Normal 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
|
Loading…
Reference in a new issue