Sha256: 6461996cc8244af0bf9449692293a995589e0826c3cf9505457116acd5361e89
Contents?: true
Size: 998 Bytes
Versions: 3
Compression:
Stored size: 998 Bytes
Contents
require 'logger' require 'weakref' require 'alfa/support' module Alfa class NullLogger def portion(*args, &block) l = self.class.new yield(l) end def info(*args) end def debug(*args) end def <<(*args) end end class Logger < ::Logger def initialize(logdev) super(nil) @logdev = logdev @formatter = Formatter.new end def portion(kwargs={}, &block) io = VirtualIO.new l = Logger.new(io) l.formatter = @formatter l.level = @level yield(l) self << io.join flush if kwargs[:sync] end def flush @logdev.flush #if @logdev.respond_to?(:flush) end private class VirtualIO < ::Array def write(message) self.push message end def close end def flush end end class Formatter < ::Logger::Formatter def call(severity, time, progname, msg) msg2str("#{msg}\n") end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
alfa-0.0.8.pre | lib/alfa/logger.rb |
alfa-0.0.7.pre | lib/alfa/logger.rb |
alfa-0.0.6.pre | lib/alfa/logger.rb |