Class: Loggability::Formatter::Structured
- Inherits:
-
Loggability::Formatter
- Object
- Loggability::Formatter
- Loggability::Formatter::Structured
- Defined in:
- lib/loggability/formatter/structured.rb
Overview
Output logs as JSON.
Constant Summary collapse
- LOG_FORMAT_VERSION =
The version of the format output
1
Instance Attribute Summary
Attributes inherited from Loggability::Formatter
Instance Method Summary collapse
-
#call(severity, time, progname, message) ⇒ Object
Format a message of the specified
severity
using the giventime
,progname
, andmessage
.
Methods inherited from Loggability::Formatter
Instance Method Details
#call(severity, time, progname, message) ⇒ Object
Format a message of the specified severity
using the given time
, progname
, and message
.
20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/loggability/formatter/structured.rb', line 20 def call( severity, time, progname, ) severity ||= 'DEBUG' time ||= Time.now entry = { '@version' => LOG_FORMAT_VERSION, '@timestamp' => time.iso8601( 3 ), 'level' => severity, 'progname' => progname, 'message' => , } return JSON.generate( entry ) end |