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



35
36
37
38
39
40
41
42
43
44
45
# File 'lib/syslogger/logger.rb', line 35

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

#appnameObject



23
24
25
# File 'lib/syslogger/logger.rb', line 23

def appname
  @default_formatter.appname
end

#appname=(appname) ⇒ Object



19
20
21
# File 'lib/syslogger/logger.rb', line 19

def appname=(appname)
  @default_formatter.appname = appname
end

#procidObject



31
32
33
# File 'lib/syslogger/logger.rb', line 31

def procid
  @default_formatter.appname
end

#procid=(procid) ⇒ Object



27
28
29
# File 'lib/syslogger/logger.rb', line 27

def procid=(procid)
  @default_formatter.procid = procid
end