Class: Ougai::Formatters::Bunyan
- Defined in:
- lib/ougai/formatters/bunyan.rb
Overview
A JSON formatter compatible with node-bunyan
Instance Attribute Summary collapse
-
#jsonize ⇒ Boolean
Whether log should converts JSON (by default this is on).
-
#with_newline ⇒ Boolean
Whether tailing NL should be appended (by default this is on).
Attributes inherited from Base
#app_name, #hostname, #trace_indent, #trace_max_lines
Instance Method Summary collapse
- #call(severity, time, progname, data) ⇒ Object
-
#initialize ⇒ Bunyan
constructor
A new instance of Bunyan.
- #to_level(severity) ⇒ Object
Methods inherited from Base
#serialize_exc, #serialize_trace
Constructor Details
#initialize ⇒ Bunyan
Returns a new instance of Bunyan.
12 13 14 15 16 |
# File 'lib/ougai/formatters/bunyan.rb', line 12 def initialize super @jsonize = true @with_newline = true end |
Instance Attribute Details
#jsonize ⇒ Boolean
Whether log should converts JSON (by default this is on).
9 10 11 |
# File 'lib/ougai/formatters/bunyan.rb', line 9 def jsonize @jsonize end |
#with_newline ⇒ Boolean
Whether tailing NL should be appended (by default this is on).
9 10 11 |
# File 'lib/ougai/formatters/bunyan.rb', line 9 def with_newline @with_newline end |
Instance Method Details
#call(severity, time, progname, data) ⇒ Object
18 19 20 21 22 23 24 25 26 27 |
# File 'lib/ougai/formatters/bunyan.rb', line 18 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 |
#to_level(severity) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/ougai/formatters/bunyan.rb', line 29 def to_level(severity) case severity when 'TRACE' 10 when 'DEBUG' 20 when 'INFO' 30 when 'WARN' 40 when 'ERROR' 50 when 'FATAL' 60 else 70 end end |