Class: StompServer::LogHelper

Inherits:
Object
  • Object
show all
Defined in:
lib/stomp_server_ng.rb

Overview

Ruby Logger Level Handler.

Class Method Summary collapse

Class Method Details

.get_loglevelObject

Return the desired logging level.



81
82
83
# File 'lib/stomp_server_ng.rb', line 81

def self.get_loglevel
  @@loglevel
end

.set_loglevel(opts) ⇒ Object

Set the desired logger level.



67
68
69
70
71
72
73
74
75
76
77
# File 'lib/stomp_server_ng.rb', line 67

def self.set_loglevel(opts)
  @@loglevel = nil
  case opts[:log_level].downcase
    when 'debug' then @@loglevel = Logger::DEBUG
    when 'info'  then @@loglevel = Logger::INFO
    when 'warn'  then @@loglevel = Logger::WARN
    when 'error' then @@loglevel = Logger::ERROR
    else  
      @@loglevel = Logger::ERROR
  end
end

.showloadpath(logger) ⇒ Object

Show load path



119
120
121
122
123
124
125
126
# File 'lib/stomp_server_ng.rb', line 119

def self.showloadpath(logger)
  return unless @@loglevel == Logger::DEBUG
  pos = 1
  $:.each do |lp|
    logger.debug("#{pos} #{lp}")
    pos += 1
  end
end

.showoptions(logger, opts) ⇒ Object

Clean logging of all options values.



101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
# File 'lib/stomp_server_ng.rb', line 101

def self.showoptions(logger, opts)
  logger.debug("Options Display Starts")
  # This is ugly, but it should only happen once at startup ......
  if RUBY_VERSION =~ /1.8/
    opts.keys.map {|key| key.to_s}.sort.each do |str_opt|
      optname = str_opt.to_sym
      logger.debug("Option: #{optname}=#{opts[optname]}")
    end
  else  # 1.9 version
    opts.keys.sort.each do |optname|
      logger.debug("Option: #{optname}=#{opts[optname]}")
    end
  end
  logger.debug("Options Display Ends")
end

.showversion(logger) ⇒ Object

Display ruby version information on a defined logger output destination.



88
89
90
91
92
93
94
95
96
97
# File 'lib/stomp_server_ng.rb', line 88

def self.showversion(logger)
  # stompserver version
  logger.debug "stomp_server version: #{StompServer::VERSION}"
  # ruby version for all versions
  logger.debug "ruby: ver=#{RUBY_VERSION}p#{RUBY_PATCHLEVEL} (reldate=#{RUBY_RELEASE_DATE})"
  # more ruby version information for 1.9+
  if RUBY_VERSION =~ /1.9/
    logger.debug "ruby: rev=#{RUBY_REVISION} engine=#{RUBY_ENGINE}"
  end
end