Class: Logtail::Logger::AugmentedFormatter
- Defined in:
- lib/logtail/logger.rb
Overview
Structures your log messages as strings and appends metadata if ‘Logtail::Config.instance.append_metadata?` is true.
Example message with metdata:
My log message @metadata {"level":"info","dt":"2016-09-01T07:00:00.000000-05:00"}
Constant Summary collapse
- METADATA_CALLOUT =
" @metadata ".freeze
- NEW_LINE =
"\n".freeze
- ESCAPED_NEW_LINE =
"\\n".freeze
Constants inherited from Formatter
Formatter::EMPTY_ARRAY, Formatter::SEVERITY_MAP
Instance Method Summary collapse
Instance Method Details
#call(severity, time, progname, msg) ⇒ Object
91 92 93 94 95 96 97 |
# File 'lib/logtail/logger.rb', line 91 def call(severity, time, progname, msg) log_entry = build_log_entry(severity, time, progname, msg) = log_entry.to_json(:except => [:message]) # use << for concatenation for performance reasons log_entry..gsub(NEW_LINE, ESCAPED_NEW_LINE) << METADATA_CALLOUT << << NEW_LINE end |