Class: SysLogger::Logger

Inherits:
MonoLogger
  • Object
show all
Defined in:
lib/syslogger/logger.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(logdev = nil, shift_age = 0, shift_size = 1048576, &block) ⇒ Logger

Returns a new instance of Logger.



7
8
9
10
11
12
13
14
15
16
17
# File 'lib/syslogger/logger.rb', line 7

def initialize(logdev = nil, shift_age = 0, shift_size = 1048576, &block)
  if logdev.nil? && block_given?
    super(SysLogger::IO.new(&block), shift_age, shift_size)
  elsif logdev.nil?
    super($stdout, shift_age, shift_size)
  else
    super(logdev, shift_age, shift_size)
  end

  @default_formatter = SysLogger::Formatter::RFC5424.new
end

Instance Attribute Details

#default_formatterObject (readonly)

Returns the value of attribute default_formatter.



5
6
7
# File 'lib/syslogger/logger.rb', line 5

def default_formatter
  @default_formatter
end

#logdevObject (readonly)

Returns the value of attribute logdev.



5
6
7
# File 'lib/syslogger/logger.rb', line 5

def logdev
  @logdev
end

Instance Method Details

#<<(msg) ⇒ Object Also known as: write



19
20
21
22
23
24
25
26
27
28
29
# File 'lib/syslogger/logger.rb', line 19

def <<(msg)
  # Logger's version of this just dumps the input without formatting. there
  # is never a case where we don't want to format the content to the syslog
  # server properly.
  # default to a serverity of info.
  msg.split(/\r?\n/).each { |line|
      if line then
          self.info(line)
      end
  }
end