Class: Pmux::Gateway::SyslogWrapper
- Inherits:
-
Object
- Object
- Pmux::Gateway::SyslogWrapper
- Includes:
- Singleton
- Defined in:
- lib/pmux-gw/syslog_wrapper.rb
Constant Summary collapse
- @@facility_map =
{ 'user' => Syslog::LOG_USER, 'daemon' => Syslog::LOG_DAEMON, 'local0' => Syslog::LOG_LOCAL0, 'local1' => Syslog::LOG_LOCAL1, 'local2' => Syslog::LOG_LOCAL2, 'local3' => Syslog::LOG_LOCAL3, 'local4' => Syslog::LOG_LOCAL4, 'local5' => Syslog::LOG_LOCAL5, 'local6' => Syslog::LOG_LOCAL6, 'local7' => Syslog::LOG_LOCAL7 }
Instance Method Summary collapse
- #get_facility(facility) ⇒ Object
- #logging(id, serverity, msg) ⇒ Object
- #open(use_syslog, facility_string) ⇒ Object
Instance Method Details
#get_facility(facility) ⇒ Object
22 23 24 25 26 27 |
# File 'lib/pmux-gw/syslog_wrapper.rb', line 22 def get_facility facility if !facility.nil? && @@facility_map.key?(facility) return @@facility_map[facility] end return Syslog::LOG_USER end |
#logging(id, serverity, msg) ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/pmux-gw/syslog_wrapper.rb', line 41 def logging id, serverity, msg return if !@syslog case serverity when "debug" Syslog.debug("[#{id}] #{msg}") when "info" Syslog.info("[#{id}] #{msg}") when "notice" Syslog.notice("[#{id}] #{msg}") when "warn" Syslog.warning("[#{id}] #{msg}") when "error" Syslog.err("[#{id}] #{msg}") when "fatal" Syslog.crit("[#{id}] #{msg}") when "alert" Syslog.alert("[#{id}] #{msg}") when "emerg" Syslog.emerg("[#{id}] #{msg}") end end |
#open(use_syslog, facility_string) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/pmux-gw/syslog_wrapper.rb', line 29 def open use_syslog, facility_string if @syslog Syslog.close() @syslog = false end if use_syslog facility = get_facility(facility_string) Syslog.open("pmux-gw", Syslog::LOG_PID, facility) @syslog = true end end |