Sha256: 1922887975f8a0be345962c69d97845af413da6135533e007c770377ddea0c88
Contents?: true
Size: 1.11 KB
Versions: 1
Compression:
Stored size: 1.11 KB
Contents
module Timber module LogDevices class IO < LogDevice class HybridFormatter < Formatter def initialize(options = {}) super @date_prefix = options.key?(:date_prefix) ? options[:date_prefix] : false end def date_prefix? @date_prefix == true end def format(log_line) "#{log_line.message}#{context_message(log_line)}" end private def base_message(log_line) text = "" if date_prefix? text << "#{log_line.formatted_dt} " end text << log_line.message text end def context_message(log_line) # The callout must be before the formatting, otherwise we leave # the message ending with a color formatting and not a reset. # Anything before the callout modifies the original message. CALLOUT + ansi_format(DARK_GRAY, encoded_context(log_line)) end def encoded_context(log_line) log_line.context_snapshot.to_logfmt end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
timberio-1.0.0.beta1 | lib/timber/log_devices/io/hybrid_formatter.rb |