Class: Logging::Layouts::Json
- Inherits:
-
Parseable
- Object
- Parseable
- Logging::Layouts::Json
- Defined in:
- lib/logging/layouts/json.rb
Instance Method Summary collapse
- #format(event) ⇒ Object
-
#initialize(opts = {}) ⇒ Json
constructor
A new instance of Json.
Constructor Details
#initialize(opts = {}) ⇒ Json
Returns a new instance of Json.
8 9 10 11 |
# File 'lib/logging/layouts/json.rb', line 8 def initialize(opts = {}) opts[:style] = 'json' super(opts) end |
Instance Method Details
#format(event) ⇒ Object
13 14 15 16 17 18 19 20 21 |
# File 'lib/logging/layouts/json.rb', line 13 def format(event) result = { 'logger' => event.logger, 'timestamp' => iso8601_format(event.time), 'level' => ::Logging::LNAMES[event.level] } result.merge!(log_hash(event)) MultiJson.encode(result) << "\n" end |