Sha256: c4c711a3d667c6234825afda58c0a89856f7ee6d6a2d70adc45f11084fb1470e
Contents?: true
Size: 915 Bytes
Versions: 1
Compression:
Stored size: 915 Bytes
Contents
require 'itamae' require 'logger' module Itamae module Logger class Formatter def call(severity, datetime, progname, msg) "[%s] %5s : %s\n" % [format_datetime(datetime), severity, msg2str(msg)] end private def format_datetime(time) time.strftime("%Y-%m-%dT%H:%M:%S.") << "%06d" % time.usec end def msg2str(msg) case msg when ::String msg when ::Exception "#{ msg.message } (#{ msg.class })\n" << (msg.backtrace || []).join("\n") else msg.inspect end end end def self.logger @logger ||= ::Logger.new($stdout).tap do |logger| logger.formatter = Formatter.new end end def self.logger=(l) @logger = l end def self.method_missing(method, *args, &block) logger.public_send(method, *args, &block) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
itamae-1.0.0.beta1 | lib/itamae/logger.rb |