Sha256: c38548a6175a37b38fc0069cb8086a0ce9296dd93547bf278232420dc8e2e69b
Contents?: true
Size: 1.22 KB
Versions: 2
Compression:
Stored size: 1.22 KB
Contents
module Bunto class Stevenson < ::Logger def initialize @progname = nil @level = DEBUG @default_formatter = Formatter.new @logdev = $stdout @formatter = proc do |_, _, _, msg| msg.to_s end end def add(severity, message = nil, progname = nil) severity ||= UNKNOWN @logdev = logdevice(severity) if @logdev.nil? || severity < @level return true end progname ||= @progname if message.nil? if block_given? message = yield else message = progname progname = @progname end end @logdev.puts( format_message(format_severity(severity), Time.now, progname, message) ) true end # Log a +WARN+ message def warn(progname = nil, &block) add(WARN, nil, progname.yellow, &block) end # Log an +ERROR+ message def error(progname = nil, &block) add(ERROR, nil, progname.red, &block) end def close # No LogDevice in use end private def logdevice(severity) if severity > INFO $stderr else $stdout end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
bunto-3.4.5 | lib/bunto/stevenson.rb |
bunto-3.2.1 | lib/bunto/stevenson.rb |