module Autostager::Logger
Interface to Posix syslog.
Public Instance Methods
log(msg, level = :info)
click to toggle source
Log a message to syslog at a specified priority level
priority level must be one of:
-
:crit
-
:emerg emergency
-
:alert
-
:err
-
:warning
-
:notice
-
:info (default if level is not specified)
-
:debug
@param msg [String] the message you want to send to syslog @param level [Symbol] the priority of the message
# File lib/autostager/logger.rb, line 23 def log(msg, level = :info) msg = safe(msg) warn "#{Time.now} #{msg}" if ENV.key?('debug') Syslog.open($PROGRAM_NAME, Syslog::LOG_PID | Syslog::LOG_CONS) do |s| s.send(level, '%s', msg) end end
safe(str)
click to toggle source
Make a string safe for syslog. @see goo.gl/hcDiqu
@param [String] A string that could be unsafe.
@return [String] A safe copy of the original string.
# File lib/autostager/logger.rb, line 37 def safe(str) CGI.unescape(str) end