Sha256: 4d3aa1c7e3cf5bc39166371af2373d39849bb818b273a4b4b235f43ba6a2d492
Contents?: true
Size: 1.96 KB
Versions: 46
Compression:
Stored size: 1.96 KB
Contents
module SiteHook module Loggers class Git def initialize(base:, level:) @@levels = { unknown: ::Logger::UNKNOWN, fatal: ::Logger::FATAL, error: ::Logger::ERROR, info: ::Logger::INFO, debug: ::Logger::DEBUG } @@loggers = { stdout: ::Logger.new(STDOUT, progname: base), stderr: ::Logger.new(STDERR, progname: base), file: ::Logger.new(SiteHook::Paths.make_log_name(base, level), progname: base) } @@loggers.each do |_logger, obj| obj.datetime_format = '%Y-%m-%dT%H:%M:%S%Z' obj.formatter = proc do |severity, datetime, progname, msg| "#{severity} [#{datetime}] #{progname} —— #{msg}\n" end end end def unknown(obj) @@loggers.each do |key, value| next if key == :stderr value.unknown(obj) end end def error(obj) @@loggers.each do |key, value| next if key == :stderr value.error(obj) end end def info(obj) @@loggers.each do |key, value| next if key == :stderr value.info(obj) end end def fatal(obj) @@loggers.each do |key, value| next if key == :stderr value.fatal(obj) end end def warn(obj) @@loggers.each do |key, value| value.warn(obj) end end def debug(obj) @@loggers.each do |key, value| next if key == :stderr value.debug(obj) end end # @param [Symbol] level log level to log at # @param [Object] obj some kind of object or msg to log def self.log(level, obj) @@loggers.each do |logger| logger.add(@levels[level], obj) end end def self.log_raw(msg) @@loggers.each do |logger| logger.<<(obj) end end end end end
Version data entries
46 entries across 46 versions & 1 rubygems