Class: Ougai::Formatters::ConnectFormatter
- Inherits:
-
Base
- Object
- Base
- Ougai::Formatters::ConnectFormatter
- Includes:
- ForJson
- Defined in:
- lib/logging/connect_formatter.rb
Overview
A JSON formatter compatible with node-bunyan
Instance Method Summary collapse
- #_call(severity, time, progname, data) ⇒ Object
- #convert_time(data) ⇒ Object
-
#initialize(app_name = nil, hostname = nil, opts = {}) ⇒ ConnectFormatter
constructor
Intialize a formatter.
Constructor Details
#initialize(app_name = nil, hostname = nil, opts = {}) ⇒ ConnectFormatter
Intialize a formatter
19 20 21 22 23 |
# File 'lib/logging/connect_formatter.rb', line 19 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
25 26 27 28 29 30 31 32 |
# File 'lib/logging/connect_formatter.rb', line 25 def _call(severity, time, progname, data) dump({ name: progname || @app_name, pid: $$, level: severity, timestamp: time.utc.strftime('%FT%T.%6NZ'), }.merge(data.merge({message: data.delete(:msg)}))) end |
#convert_time(data) ⇒ Object
34 35 36 |
# File 'lib/logging/connect_formatter.rb', line 34 def convert_time(data) #data[:timestamp] = format_datetime(data[:time]) end |