Sha256: 16b1d127c9454fc8588a28e105d109cd7070e87bfea0c0cb371d30bfbf1818c5
Contents?: true
Size: 1.12 KB
Versions: 1
Compression:
Stored size: 1.12 KB
Contents
module Timber module LogDevices class IO < LogDevice class HybridHiddenFormatter < HybridFormatter CLEAR_SEQUENCE = "\e8\e[K".freeze CLEAR_STEP_SIZE = 20.freeze SAVE_CURSOR_POSITION = "\e7".freeze def format(log_line) "#{SAVE_CURSOR_POSITION}#{context_message(log_line)}#{base_message(log_line)}" end private def context_message(log_line) text = encoded_context(log_line) position = CLEAR_STEP_SIZE sequence_size = CLEAR_SEQUENCE.size step_size = sequence_size + CLEAR_STEP_SIZE while position < text.length # ensure we don't insert before a \ while text[position - 1] == "\\" position += 1 end text.insert(position, CLEAR_SEQUENCE) position += step_size end ansi_format(DARK_GRAY, "#{CALLOUT}#{CLEAR_SEQUENCE}#{text} #{CALLOUT_END}#{CLEAR_SEQUENCE}") 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_hidden_formatter.rb |