Class: OverSIP::SysLoggerProcess::SysLoggerWatcher

Inherits:
EM::PosixMQ::Watcher
  • Object
show all
Defined in:
lib/oversip/syslogger_process.rb

Instance Method Summary collapse

Instance Method Details

#receive_message(string, priority) ⇒ Object



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/oversip/syslogger_process.rb', line 40

def receive_message string, priority
  level = string.getbyte 0
  msg   = string[1..-1].gsub(/%/,"%%").gsub(/\x00/,"")

  case level
  when 48  # "0" =>DEBUG
    ::Syslog.debug sprintf("%7s %s", "DEBUG:", msg)
  when 49  # "1" => INFO
    ::Syslog.info sprintf("%7s %s", "INFO:", msg)
  when 50  # "2" => NOTICE
    ::Syslog.notice sprintf("%7s %s", "NOTICE:", msg)
  when 51  # "3" => WARN
    ::Syslog.warning sprintf("%7s %s", "WARN:", msg)
  when 52  # "4" => ERR
    ::Syslog.err sprintf("%7s %s", "ERROR:", msg)
  when 53  # "5" => CRIT
    ::Syslog.crit sprintf("%7s %s", "CRIT:", msg)
  when 54  # "6" => ALERT
    ::Syslog.alert sprintf("%7s %s", "ALERT:", msg)
  when 55  # "7" => EMERG
    ::Syslog.emerg sprintf("%7s %s", "EMERG:", msg)
  else  # Shouldn't occur.
    ::Syslog.err sprintf("%7s %s", "UNKNOWN:", msg)
  end
end