Sha256: d68aba1fbccdd1958bc699d8e7f7d059de289e7f05c8fb30087cba5dcab30b9b
Contents?: true
Size: 973 Bytes
Versions: 19
Compression:
Stored size: 973 Bytes
Contents
module CopycopterClient class PrefixedLogger attr_reader :prefix, :original_logger def initialize(prefix, logger) @prefix = prefix @original_logger = logger end def info(message = nil, &block) log(:info, message, &block) end def debug(message = nil, &block) log(:debug, message, &block) end def warn(message = nil, &block) log(:warn, message, &block) end def error(message = nil, &block) log(:error, message, &block) end def fatal(message = nil, &block) log(:fatal, message, &block) end def flush original_logger.flush if original_logger.respond_to?(:flush) end private def log(severity, message, &block) prefixed_message = "#{prefix} #{thread_info} #{message}" original_logger.send(severity, prefixed_message, &block) end def thread_info "[P:#{Process.pid}] [T:#{Thread.current.object_id}]" end end end
Version data entries
19 entries across 19 versions & 1 rubygems