Class: Timber::Logger::HybridFormatter
- Inherits:
-
Formatter
- Object
- Formatter
- Timber::Logger::HybridFormatter
- Defined in:
- lib/timber/logger.rb
Overview
Structures your log messages into Timber’s hybrid format, which makes it easy to read while also appending the appropriate metadata.
logger = Timber::Logger.new(STDOUT)
logger.formatter = Timber::JSONFormatter.new
Example message:
My log message @timber.io {"level":"info","dt":"2016-09-01T07:00:00.000000-05:00"}
Constant Summary collapse
- METADATA_CALLOUT =
"@timber.io".freeze
Instance Method Summary collapse
Instance Method Details
#call(severity, time, progname, msg) ⇒ Object
113 114 115 116 117 118 |
# File 'lib/timber/logger.rb', line 113 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("\n", "\\n") << " " << METADATA_CALLOUT << " " << << "\n" end |