Class: Ougai::Formatters::Bunyan
- Includes:
- ForJson
- Defined in:
- lib/ougai/formatters/bunyan.rb
Overview
A JSON formatter compatible with node-bunyan
Instance Attribute Summary
Attributes included from ForJson
Attributes inherited from Base
#app_name, #hostname, #serialize_backtrace, #trace_indent, #trace_max_lines
Instance Method Summary collapse
- #_call(severity, time, progname, data) ⇒ Object
- #convert_time(data) ⇒ Object
-
#initialize(app_name = nil, hostname = nil, opts = {}) ⇒ Bunyan
constructor
Intialize a formatter.
Methods inherited from Base
#call, #datetime_format=, #serialize_exc, #serialize_trace
Constructor Details
#initialize(app_name = nil, hostname = nil, opts = {}) ⇒ Bunyan
Intialize a formatter
20 21 22 23 24 |
# File 'lib/ougai/formatters/bunyan.rb', line 20 def initialize(app_name = nil, hostname = nil, opts = {}) aname, hname, opts = Base.parse_new_params([app_name, hostname, opts]) super(aname, hname, opts) init_opts_for_json(opts) end |
Instance Method Details
#_call(severity, time, progname, data) ⇒ Object
26 27 28 29 30 31 32 33 34 35 |
# File 'lib/ougai/formatters/bunyan.rb', line 26 def _call(severity, time, progname, data) dump({ name: progname || @app_name, hostname: @hostname, pid: $$, level: to_level(severity), time: time, v: 0 }.merge(data)) end |
#convert_time(data) ⇒ Object
37 38 39 |
# File 'lib/ougai/formatters/bunyan.rb', line 37 def convert_time(data) data[:time] = format_datetime(data[:time]) end |