Class: Aruba::ArubaLogger
- Inherits:
-
Object
- Object
- Aruba::ArubaLogger
- Defined in:
- lib/aruba/platforms/aruba_logger.rb
Overview
Logger
Instance Attribute Summary collapse
-
#mode ⇒ Object
Returns the value of attribute mode.
Instance Method Summary collapse
-
#debug(msg) ⇒ Object
Log a debug level log message.
-
#error(msg) ⇒ Object
Log an error level log message.
-
#fatal(msg) ⇒ Object
Log a fatal level log message.
-
#info(msg) ⇒ Object
Log an info level log message.
-
#initialize(opts = {}) ⇒ ArubaLogger
constructor
Create logger.
-
#logger ⇒ Object
Create new logger on every invocation to make capturing $stderr possible.
-
#mode?(m) ⇒ Boolean
Is mode?.
-
#unknown(msg) ⇒ Object
Log an unknown level log message.
-
#warn(msg) ⇒ Object
Log a warn level log message.
Constructor Details
#initialize(opts = {}) ⇒ ArubaLogger
Create logger
17 18 19 |
# File 'lib/aruba/platforms/aruba_logger.rb', line 17 def initialize(opts = {}) @mode = opts.fetch(:default_mode, :info) end |
Instance Attribute Details
#mode ⇒ Object
Returns the value of attribute mode.
9 10 11 |
# File 'lib/aruba/platforms/aruba_logger.rb', line 9 def mode @mode end |
Instance Method Details
#debug(msg) ⇒ Object
Log a debug level log message
|
# File 'lib/aruba/platforms/aruba_logger.rb', line 27
|
#error(msg) ⇒ Object
Log an error level log message
|
# File 'lib/aruba/platforms/aruba_logger.rb', line 33
|
#fatal(msg) ⇒ Object
Log a fatal level log message
|
# File 'lib/aruba/platforms/aruba_logger.rb', line 21
|
#info(msg) ⇒ Object
Log an info level log message
|
# File 'lib/aruba/platforms/aruba_logger.rb', line 30
|
#logger ⇒ Object
Create new logger on every invocation to make capturing $stderr possible
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# 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 |
#mode?(m) ⇒ Boolean
Is mode?
72 73 74 |
# File 'lib/aruba/platforms/aruba_logger.rb', line 72 def mode?(m) mode == m.to_sym end |
#unknown(msg) ⇒ Object
Log an unknown level log message
39 40 41 42 43 |
# File 'lib/aruba/platforms/aruba_logger.rb', line 39 [:fatal, :warn, :debug, :info, :error, :unknown].each do |m| define_method m do |msg| logger.public_send m, msg end end |
#warn(msg) ⇒ Object
Log a warn level log message
|
# File 'lib/aruba/platforms/aruba_logger.rb', line 24
|