Skip to content

Commit

Permalink
Crystal 1.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
taylorfinnell committed Apr 13, 2021
1 parent b5b6692 commit da41e54
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 16 deletions.
6 changes: 4 additions & 2 deletions shard.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
name: hqtrivia
version: 0.7.0
version: 0.7.1

authors:
- Taylor Finnell <[email protected]>

crystal: 0.32.0
crystal: ">= 0.32.0"

license: MIT

dependencies:
retrycr:
github: taylorfinnell/retrycr
json_mapping:
github: crystal-lang/json_mapping.cr
1 change: 1 addition & 0 deletions src/hqtrivia.cr
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
require "json_mapping"
require "./hqtrivia/*"

# Framework for creating HQ Trivia and HQ Words bots
Expand Down
40 changes: 27 additions & 13 deletions src/hqtrivia/logger.cr
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
require "logger"
require "log"

module HqTrivia
# A Logger class that supports setting log level from the environment.
class Logger
def initialize(@logger : ::Logger = ::Logger.new(STDOUT))
def initialize(@logger : ::Log = ::Log.for("hqtrivia"))
@logger.level = log_level
end

Expand All @@ -16,24 +16,38 @@ module HqTrivia
private def log_level
case ENV["LOG_LEVEL"]?.to_s.upcase
when "DEBUG"
::Logger::Severity::DEBUG
::Log::Severity::Debug
when "INFO"
::Logger::Severity::INFO
::Log::Severity::Info
when "WARN"
::Logger::Severity::WARN
::Log::Severity::Warn
when "ERROR"
::Logger::Severity::ERROR
::Log::Severity::Error
when "FATAL"
::Logger::Severity::FATAL
::Log::Severity::Fatal
else
::Logger::Severity::INFO
::Log::Severity::Info
end
end

delegate debug, to: @logger
delegate info, to: @logger
delegate warn, to: @logger
delegate error, to: @logger
delegate fatal, to: @logger
def debug(msg)
@logger.debug { msg }
end

def info(msg)
@logger.info { msg }
end

def warn(msg)
@logger.warn { msg }
end

def error(msg)
@logger.error { msg }
end

def fatal(msg)
@logger.fatal { msg }
end
end
end
2 changes: 1 addition & 1 deletion src/hqtrivia/version.cr
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module HqTrivia
# Current HqTrivia version
VERSION = "0.7.0"
VERSION = "0.7.1"
end

0 comments on commit da41e54

Please sign in to comment.