Module: Autostager::Logger
- Included in:
- Autostager, CLI, PullRequest
- Defined in:
- lib/autostager/logger.rb
Overview
Interface to Posix syslog.
Class Method Summary collapse
-
.log(msg, level = :info) ⇒ Object
Log a message to syslog at a specified priority level.
-
.safe(str) ⇒ String
Make a string safe for syslog.
Class Method Details
.log(msg, level = :info) ⇒ Object
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
23 24 25 26 27 28 29 |
# 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) ⇒ String
Make a string safe for syslog.
37 38 39 |
# File 'lib/autostager/logger.rb', line 37 def safe(str) CGI.unescape(str) end |