class Aruba::ArubaLogger
Logger
@private
Attributes
Public Class Methods
Source
# File lib/aruba/platforms/aruba_logger.rb, line 17 def initialize(opts = {}) @mode = opts.fetch(:default_mode, :info) end
Create logger
@param [Hash] opts
Options
@option opts [Symbol] :default_mode Log level
Public Instance Methods
Source
# File lib/aruba/platforms/aruba_logger.rb, line 47 def logger l = ::Logger.new($stderr) if mode == :debug format_debug(l) else format_standard(l) end l.level = case mode when :debug ::Logger::DEBUG when :silent 9_999 else ::Logger::INFO end l end
Create new logger on every invocation to make capturing $stderr possible
Source
# File lib/aruba/platforms/aruba_logger.rb, line 80 def mode=(m) @mode = m.to_sym end
Change mode of logger: :debug, … + Change the output format
@param [Symbol] m
the mode: :debug, ...
Source
# File lib/aruba/platforms/aruba_logger.rb, line 72 def mode?(m) mode == m.to_sym end
Is mode?
@param [String, Symbol] m
Mode to compare with
Private Instance Methods
Source
# File lib/aruba/platforms/aruba_logger.rb, line 86 def format_debug(l) l.formatter = proc { |severity, datetime, progname, msg| format("%s %s %s: %s\n", datetime, severity, progname, msg) } end
Source
# File lib/aruba/platforms/aruba_logger.rb, line 92 def format_standard(l) l.formatter = proc { |severity, datetime, _, msg| format("%s %s: %s\n", datetime, severity, msg) } end