Sha256: 9e6f2a0f821eaa2445bdd0b679492c6c5381ac8656cc984e0417f73784dc049a
Contents?: true
Size: 1.43 KB
Versions: 1
Compression:
Stored size: 1.43 KB
Contents
require 'logger' module UnitF module Logging DEBUG = ::Logger::Severity::DEBUG INFO = ::Logger::Severity::INFO WARN = ::Logger::Severity::WARN ERROR = ::Logger::Severity::ERROR FATAL = ::Logger::Severity::FATAL class Logger def initialize(level = INFO) @writers = [] @console = nil @level = ENV['UNITF_LOG_LEVEL'] || level end def add_writer(writer) @writers << writer writer.level = @level end def debug(message) write(DEBUG, message) end def info(message) write(INFO, message) end def warn(message) write(WARN, message) end def error(message) write(ERROR, message) end def fatal(message) write(FATAL, message) end def level=(level) level = UnitF::Logging.const_get(level.upcase) if level.is_a?(String) @level = level @writers.each do |writer| writer.level = level end end def console @writers.each do |writer| return writer if writer.is_a?(UnitF::Logging::ConsoleWriter) end nil end def dump @writers.each do |writer| puts "Name: #{writer.name} Type: #{writer.class}" end end def write(severity, message) @writers.each do |writer| writer.log(severity, message) end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
unitf-logging-0.1.0 | lib/unitf/logging/logger.rb |