Module: Moon::Logfmt::StdlibLoggable
Overview
Interface for the stdlib Logger class
Constant Summary
Constants included from Severity
Moon::Logfmt::Severity::DEBUG, Moon::Logfmt::Severity::ERROR, Moon::Logfmt::Severity::FATAL, Moon::Logfmt::Severity::INFO, Moon::Logfmt::Severity::UNKNOWN, Moon::Logfmt::Severity::WARN
std Logger interface collapse
- #add(severity, message = nil, progname = nil, &block) ⇒ Object (also: #log)
-
#debug(progname = nil, &block) ⇒ Object
See #info for more information.
-
#error(progname = nil, &block) ⇒ Object
See #info for more information.
-
#fatal(progname = nil, &block) ⇒ Object
See #info for more information.
-
#info(progname = nil, &block) ⇒ Object
Logs a message.
-
#unknown(progname = nil, &block) ⇒ Object
See #info for more information.
-
#warn(progname = nil, &block) ⇒ Object
See #info for more information.
Instance Method Details
#add(severity, message = nil, progname = nil, &block) ⇒ Object Also known as: log
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/moon-logfmt/stdlib_loggable.rb', line 28 def add(severity, = nil, progname = nil, &block) = || (block && block.call) msg = || progname data = {} data[:progname] = progname if progname && data[case severity when DEBUG then :debug when ERROR then :error when FATAL then :fatal when INFO then :msg when UNKNOWN then :msg when WARN then :warn end] = msg write data end |
#debug(progname = nil, &block) ⇒ Object
See #info for more information. (see #info)
58 59 60 |
# File 'lib/moon-logfmt/stdlib_loggable.rb', line 58 def debug(progname = nil, &block) add(DEBUG, nil, progname, &block) end |
#error(progname = nil, &block) ⇒ Object
See #info for more information. (see #info)
64 65 66 |
# File 'lib/moon-logfmt/stdlib_loggable.rb', line 64 def error(progname = nil, &block) add(ERROR, nil, progname, &block) end |
#fatal(progname = nil, &block) ⇒ Object
See #info for more information. (see #info)
70 71 72 |
# File 'lib/moon-logfmt/stdlib_loggable.rb', line 70 def fatal(progname = nil, &block) add(FATAL, nil, progname, &block) end |
#info(message) ⇒ Object #info(progname, &block) ⇒ Object
Logs a message
52 53 54 |
# File 'lib/moon-logfmt/stdlib_loggable.rb', line 52 def info(progname = nil, &block) add(INFO, nil, progname, &block) end |