Module: Ougai::Logging
Overview
Common Logging features
Defined Under Namespace
Modules: Severity
Constant Summary
Constants included from Severity
Severity::SEV_LABEL, Severity::TRACE
Instance Attribute Summary collapse
-
#before_log ⇒ Object
writeonly
Sets the attribute before_log.
-
#with_fields ⇒ Object
Returns the value of attribute with_fields.
Instance Method Summary collapse
- #_log(severity, *args) ⇒ Object
-
#add(severity, message = nil, ex = nil, data = nil, &block) ⇒ Boolean
(also: #log)
Log any one or more of a message, an exception and structured data as specified log level.
- #chain(_severity, _args, _fields, _hooks) ⇒ Object
-
#debug(message = nil, ex = nil, data = nil, &block) ⇒ Boolean
Log any one or more of a message, an exception and structured data as DEBUG.
-
#error(message = nil, ex = nil, data = nil, &block) ⇒ Boolean
Log any one or more of a message, an exception and structured data as ERROR.
-
#fatal(message = nil, ex = nil, data = nil, &block) ⇒ Boolean
Log any one or more of a message, an exception and structured data as FATAL.
-
#info(message = nil, ex = nil, data = nil, &block) ⇒ Boolean
Log any one or more of a message, an exception and structured data as INFO.
-
#trace(message = nil, ex = nil, data = nil, &block) ⇒ Boolean
Log any one or more of a message, an exception and structured data as TRACE.
-
#trace? ⇒ Boolean
Whether the current severity level allows for logging TRACE.
-
#unknown(message = nil, ex = nil, data = nil, &block) ⇒ Boolean
Log any one or more of a message, an exception and structured data as UNKNOWN.
-
#warn(message = nil, ex = nil, data = nil, &block) ⇒ Boolean
Log any one or more of a message, an exception and structured data as WARN.
Methods included from Severity
Instance Attribute Details
#before_log=(value) ⇒ Object (writeonly)
Sets the attribute before_log
7 8 9 |
# File 'lib/ougai/logging.rb', line 7 def before_log=(value) @before_log = value end |
#with_fields ⇒ Object
Returns the value of attribute with_fields.
6 7 8 |
# File 'lib/ougai/logging.rb', line 6 def with_fields @with_fields end |
Instance Method Details
#_log(severity, *args) ⇒ Object
100 101 102 103 104 |
# File 'lib/ougai/logging.rb', line 100 def _log(severity, *args) severity ||= UNKNOWN return true if level > severity append(severity, block_given? ? yield : args) end |
#add(severity, message = nil, ex = nil, data = nil, &block) ⇒ Boolean Also known as: log
Log any one or more of a message, an exception and structured data as specified log level. If the block is given for delay evaluation, it returns them as an array or the one of them as a value.
94 95 96 |
# File 'lib/ougai/logging.rb', line 94 def add(severity, = nil, ex = nil, data = nil, &block) _log(severity, , ex, data, &block) end |
#chain(_severity, _args, _fields, _hooks) ⇒ Object
107 108 109 |
# File 'lib/ougai/logging.rb', line 107 def chain(_severity, _args, _fields, _hooks) raise NotImplementedError end |
#debug(message = nil, ex = nil, data = nil, &block) ⇒ Boolean
Log any one or more of a message, an exception and structured data as DEBUG. If the block is given for delay evaluation, it returns them as an array or the one of them as a value.
41 42 43 |
# File 'lib/ougai/logging.rb', line 41 def debug( = nil, ex = nil, data = nil, &block) _log(DEBUG, , ex, data, &block) end |
#error(message = nil, ex = nil, data = nil, &block) ⇒ Boolean
Log any one or more of a message, an exception and structured data as ERROR.
62 63 64 |
# File 'lib/ougai/logging.rb', line 62 def error( = nil, ex = nil, data = nil, &block) _log(ERROR, , ex, data, &block) end |
#fatal(message = nil, ex = nil, data = nil, &block) ⇒ Boolean
Log any one or more of a message, an exception and structured data as FATAL.
69 70 71 |
# File 'lib/ougai/logging.rb', line 69 def fatal( = nil, ex = nil, data = nil, &block) _log(FATAL, , ex, data, &block) end |
#info(message = nil, ex = nil, data = nil, &block) ⇒ Boolean
Log any one or more of a message, an exception and structured data as INFO.
48 49 50 |
# File 'lib/ougai/logging.rb', line 48 def info( = nil, ex = nil, data = nil, &block) _log(INFO, , ex, data, &block) end |
#trace(message = nil, ex = nil, data = nil, &block) ⇒ Boolean
Log any one or more of a message, an exception and structured data as TRACE.
30 31 32 |
# File 'lib/ougai/logging.rb', line 30 def trace( = nil, ex = nil, data = nil, &block) _log(TRACE, , ex, data, &block) end |
#trace? ⇒ Boolean
Whether the current severity level allows for logging TRACE.
82 83 84 |
# File 'lib/ougai/logging.rb', line 82 def trace? level <= TRACE end |
#unknown(message = nil, ex = nil, data = nil, &block) ⇒ Boolean
Log any one or more of a message, an exception and structured data as UNKNOWN.
76 77 78 |
# File 'lib/ougai/logging.rb', line 76 def unknown( = nil, ex = nil, data = nil, &block) _log(UNKNOWN, , ex, data, &block) end |
#warn(message = nil, ex = nil, data = nil, &block) ⇒ Boolean
Log any one or more of a message, an exception and structured data as WARN.
55 56 57 |
# File 'lib/ougai/logging.rb', line 55 def warn( = nil, ex = nil, data = nil, &block) _log(WARN, , ex, data, &block) end |