class Aruba::ArubaLogger
@private
Logger
def format_debug(l)
def format_debug(l) l.formatter = proc { |severity, datetime, progname, msg| format("%s %s %s: %s\n", datetime, severity, progname, msg) } end
def format_standard(l)
def format_standard(l) l.formatter = proc { |severity, datetime, _, msg| format("%s %s: %s\n", datetime, severity, msg) } end
def initialize(opts = {})
(**opts)
-
:default_mode
(Symbol
) -- Log level
Parameters:
-
opts
(Hash
) --
def initialize(opts = {}) @mode = opts.fetch(:default_mode, :info) end
def logger
Create new logger on every invocation to make
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
def mode=(m)
-
m
(Symbol
) --
def mode=(m) @mode = m.to_sym end
def mode?(m)
-
m
(String, Symbol
) --
def mode?(m) mode == m.to_sym end