Class: Ougai::Formatters::Readable
- Defined in:
- lib/ougai/formatters/readable.rb
Overview
A human readble formatter with amazing_print
Instance Attribute Summary collapse
-
#excluded_fields ⇒ Array<String, Symbol>
The fields excluded from all logs.
-
#plain ⇒ Boolean
Whether log should be plain not colorized.
Attributes inherited from Base
#app_name, #hostname, #serialize_backtrace, #trace_indent, #trace_max_lines
Instance Method Summary collapse
- #_call(severity, time, progname, _data) ⇒ Object
-
#initialize(app_name = nil, hostname = nil, opts = {}) ⇒ Readable
constructor
Intialize a formatter.
- #serialize_backtrace=(value) ⇒ Object
Methods inherited from Base
#call, #datetime_format=, #serialize_exc, #serialize_trace
Constructor Details
#initialize(app_name = nil, hostname = nil, opts = {}) ⇒ Readable
Intialize a formatter
21 22 23 24 25 26 27 28 29 |
# File 'lib/ougai/formatters/readable.rb', line 21 def initialize(app_name = nil, hostname = nil, opts = {}) aname, hname, opts = Base.parse_new_params([app_name, hostname, opts]) super(aname, hname, opts) @trace_indent = opts.fetch(:trace_indent, 4) @plain = opts.fetch(:plain, false) @excluded_fields = opts[:excluded_fields] || [] @serialize_backtrace = true load_dependent end |
Instance Attribute Details
#excluded_fields ⇒ Array<String, Symbol>
The fields excluded from all logs
10 11 12 |
# File 'lib/ougai/formatters/readable.rb', line 10 def excluded_fields @excluded_fields end |
#plain ⇒ Boolean
Whether log should be plain not colorized.
10 11 12 |
# File 'lib/ougai/formatters/readable.rb', line 10 def plain @plain end |
Instance Method Details
#_call(severity, time, progname, _data) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/ougai/formatters/readable.rb', line 31 def _call(severity, time, progname, _data) data = _data.dup msg = data.delete(:msg) level = @plain ? severity : colored_level(severity) dt = format_datetime(time) err_str = create_err_str(data) @excluded_fields.each { |f| data.delete(f) } data_str = create_data_str(data) format_log_parts(dt, level, msg, err_str, data_str) end |
#serialize_backtrace=(value) ⇒ Object
43 44 45 |
# File 'lib/ougai/formatters/readable.rb', line 43 def serialize_backtrace=(value) raise NotImplementedError, 'Not support serialize_backtrace' end |