lib/pacto/logger.rb in pacto-0.3.0 vs lib/pacto/logger.rb in pacto-0.3.1

- old
+ new

@@ -1,44 +1,50 @@ require 'forwardable' module Pacto - class Logger - include Singleton - extend Forwardable + module Logger + def logger + Pacto.configuration.logger + end - def_delegators :@log, :debug, :info, :warn, :error, :fatal + class SimpleLogger + include Singleton + extend Forwardable - def initialize - log ::Logger.new STDOUT - end + def_delegators :@log, :debug, :info, :warn, :error, :fatal - def log(log) - @log = log - @log.level = default_level - @log.progname = 'Pacto' - end + def initialize + log ::Logger.new STDOUT + end - def level=(level) - @log.level = log_levels.fetch(level, default_level) - end + def log(log) + @log = log + @log.level = default_level + @log.progname = 'Pacto' + end - def level - log_levels.key @log.level - end + def level=(level) + @log.level = log_levels.fetch(level, default_level) + end - private + def level + log_levels.key @log.level + end - def default_level - ::Logger::ERROR - end + private - def log_levels - { - debug: ::Logger::DEBUG, - info: ::Logger::INFO, - warn: ::Logger::WARN, - error: ::Logger::ERROR, - fatal: ::Logger::FATAL - } + def default_level + ::Logger::ERROR + end + + def log_levels + { + debug: ::Logger::DEBUG, + info: ::Logger::INFO, + warn: ::Logger::WARN, + error: ::Logger::ERROR, + fatal: ::Logger::FATAL + } + end end end end