Sha256: 04f29d513bb54a0159af73e3d164915dc244217d5a9e8b9f1ae6a371f2b996fd
Contents?: true
Size: 1.18 KB
Versions: 4
Compression:
Stored size: 1.18 KB
Contents
begin require 'syslog' # Ensure that Syslog is open begin Syslog.open('god') rescue RuntimeError Syslog.reopen('god') end Syslog.info("Syslog enabled.") module God class SysLogger SYMBOL_EQUIVALENTS = { :fatal => Syslog::LOG_CRIT, :error => Syslog::LOG_ERR, :warn => Syslog::LOG_WARNING, :info => Syslog::LOG_INFO, :debug => Syslog::LOG_DEBUG } # Set the log level # +level+ is the Symbol level to set as maximum. One of: # [:fatal | :error | :warn | :info | :debug ] # # Returns Nothing def self.level=(level) Syslog.mask = Syslog::LOG_UPTO(SYMBOL_EQUIVALENTS[level]) end # Log a message to syslog. # +level+ is the Symbol level of the message. One of: # [:fatal | :error | :warn | :info | :debug ] # +text+ is the String text of the message # # Returns Nothing def self.log(level, text) Syslog.log(SYMBOL_EQUIVALENTS[level], text) end end end rescue Object => e puts "Syslog could not be enabled: #{e.message}" end
Version data entries
4 entries across 4 versions & 2 rubygems
Version | Path |
---|---|
firenxis-god-0.11.0 | lib/god/sys_logger.rb |
god-0.11.0 | lib/god/sys_logger.rb |
god-0.10.1 | lib/god/sys_logger.rb |
god-0.9.0 | lib/god/sys_logger.rb |