Parent

Class/Module Index [+]

Quicksearch

OpenShift::Runtime::NodeLogger::SyslogLogger

This NodeLogger implementation is backed by the Ruby stdlib syslog package. Logs are written using the +Syslog::LOG_LOCAL0+ facility.

The priority threshold is configured by the PLATFORM_SYSLOG_THRESHOLD config key, which is a string matching one of the log priority values specified in the Ruby syslog package:

http://ruby-doc.org/stdlib-1.9.3/libdoc/syslog/rdoc/Syslog.html#method-c-log

If the PLATFORM_SYSLOG_TRACE_ENABLED config value is 1, trace logs will be written using the LOG_DEBUG priority.

Note: This implementation does not support deferred log entry evaluation. Any blocks passed to log methods will be immediately evaluated.

Public Class Methods

new(config=nil) click to toggle source
# File lib/openshift-origin-node/utils/logger/syslog_logger.rb, line 41
def initialize(config=nil)
  @config = config
  @trace_enabled = (@config.get('PLATFORM_SYSLOG_TRACE_ENABLED') || '1').to_i == 1

  threshold_config = @config.get('PLATFORM_SYSLOG_THRESHOLD') || 'LOG_DEBUG'
  begin
    @threshold = Syslog.const_get(threshold_config)
  rescue Exception => e
    raise "Invalid PLATFORM_SYSLOG_THRESHOLD value '#{threshold_config}': #{e.message}"
  end

  reinitialize
end

Public Instance Methods

debug(*args, &block) click to toggle source
# File lib/openshift-origin-node/utils/logger/syslog_logger.rb, line 64
def debug(*args, &block)
  Syslog.log(Syslog::LOG_DEBUG, build_entry(*args, &block))
end
error(*args, &block) click to toggle source
# File lib/openshift-origin-node/utils/logger/syslog_logger.rb, line 72
def error(*args, &block)
  Syslog.log(Syslog::LOG_ERR, build_entry(*args, &block))
end
fatal(*args, &block) click to toggle source
# File lib/openshift-origin-node/utils/logger/syslog_logger.rb, line 76
def fatal(*args, &block)
  Syslog.log(Syslog::LOG_CRIT, build_entry(*args, &block))
end
info(*args, &block) click to toggle source
# File lib/openshift-origin-node/utils/logger/syslog_logger.rb, line 60
def info(*args, &block)
  Syslog.log(Syslog::LOG_INFO, build_entry(*args, &block))
end
reinitialize() click to toggle source
# File lib/openshift-origin-node/utils/logger/syslog_logger.rb, line 55
def reinitialize
  Syslog.open('openshift-platform', Syslog::LOG_PID, Syslog::LOG_LOCAL0) unless Syslog.opened?
  Syslog.mask = Syslog::LOG_UPTO(@threshold)
end
trace(*args, &block) click to toggle source
# File lib/openshift-origin-node/utils/logger/syslog_logger.rb, line 80
def trace(*args, &block)
  return unless @trace_enabled
  Syslog.log(Syslog::LOG_DEBUG, build_entry(*args, &block))
end
warn(*args, &block) click to toggle source
# File lib/openshift-origin-node/utils/logger/syslog_logger.rb, line 68
def warn(*args, &block)
  Syslog.log(Syslog::LOG_WARNING, build_entry(*args, &block))
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.