class Bluepill::Logger

Constants

LOG_METHODS

Public Class Methods

new(options = {}) click to toggle source
# File lib/bluepill/logger.rb, line 5
def initialize(options = {})
  @options  = options
  @logger   = options[:logger] || create_logger
  @prefix   = options[:prefix]
  @stdout   = options[:stdout]
  @prefixes = {}
end

Public Instance Methods

prefix_with(prefix) click to toggle source
# File lib/bluepill/logger.rb, line 30
def prefix_with(prefix)
  @prefixes[prefix] ||= self.class.new(logger: self, prefix: prefix)
end
reopen() click to toggle source
# File lib/bluepill/logger.rb, line 34
def reopen
  if @logger.is_a?(self.class)
    @logger.reopen
  else
    @logger = create_logger
  end
end

Protected Instance Methods

create_logger() click to toggle source
# File lib/bluepill/logger.rb, line 44
def create_logger
  if @options[:log_file]
    LoggerAdapter.new(@options[:log_file])
  else
    Syslog.close if Syslog.opened? # need to explictly close it before reopening it
    Syslog.open(@options[:identity] || 'bluepilld', Syslog::LOG_PID, Syslog::LOG_LOCAL6)
  end
end