Sha256: abc4314dfaff8709c3a4ac2dcd2786d4eaff46e723a32edfc60e630054b8d5d3
Contents?: true
Size: 845 Bytes
Versions: 20
Compression:
Stored size: 845 Bytes
Contents
module Bluepill class Logger LOG_METHODS = [:emerg, :alert, :crit, :err, :warning, :notice, :info, :debug] def initialize(options = {}) @logger = options[:logger] || Syslog.open(options[:identity] || 'bluepilld', Syslog::LOG_PID, Syslog::LOG_LOCAL6) @prefix = options[:prefix] @prefixes = {} end LOG_METHODS.each do |method| eval <<-END def #{method}(msg, prefix = []) if @logger.is_a?(self.class) @logger.#{method}(msg, [@prefix] + prefix) else prefix = prefix.size > 0 ? "[\#{prefix.compact.join(':')}] " : "" @logger.#{method}("\#{prefix}\#{msg}") end end END end def prefix_with(prefix) @prefixes[prefix] ||= self.class.new(:logger => self, :prefix => prefix) end end end
Version data entries
20 entries across 20 versions & 1 rubygems