Class: U::Log::Compat
- Inherits:
-
Object
- Object
- U::Log::Compat
- Defined in:
- lib/u-log/compat.rb
Overview
Backward-compatible with the stdlib Logger ruby-doc.org/stdlib-2.0/libdoc/logger/rdoc/Logger.html
Constant Summary collapse
- LEVELS =
{ 0 => :debug, 1 => :info, 2 => :warn, 3 => :error, 4 => :fatal, 5 => :unknown, }
Instance Attribute Summary collapse
-
#ulogger ⇒ Object
readonly
Returns the value of attribute ulogger.
Instance Method Summary collapse
-
#initialize(ulogger) ⇒ Compat
constructor
A new instance of Compat.
- #log(severity, message = nil, progname = nil, &block) ⇒ Object
- #noop ⇒ Object
Constructor Details
#initialize(ulogger) ⇒ Compat
Returns a new instance of Compat.
16 17 18 |
# File 'lib/u-log/compat.rb', line 16 def initialize(ulogger) @ulogger = ulogger end |
Instance Attribute Details
#ulogger ⇒ Object (readonly)
Returns the value of attribute ulogger.
14 15 16 |
# File 'lib/u-log/compat.rb', line 14 def ulogger @ulogger end |
Instance Method Details
#log(severity, message = nil, progname = nil, &block) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/u-log/compat.rb', line 20 def log(severity, = nil, progname = nil, &block) pri = LEVELS[severity] || severity if block_given? progname = = yield rescue $! end data = { pri: pri } data[:app] = progname if progname data[:msg] = if @ulogger.log(data) end |
#noop ⇒ Object
41 |
# File 'lib/u-log/compat.rb', line 41 def noop(*); true end |