Browse Source

space_prefix

pagy
pvincent 11 months ago
parent
commit
1c0c681c89
  1. 8
      lib/formatters/basic_formatter.rb

8
lib/formatters/basic_formatter.rb

@ -55,7 +55,9 @@ class BasicFormatter < SemanticLogger::Formatters::Color
end
wrap_length = IO.console.winsize[1] - FOREMAN_PREFIX - before_message.length + CONTENT_PREFIX.length + 12
message = Wrapper.wrap("#{CONTENT_COLOR_MAP[log.level]}#{message.lstrip}", before_message(true), wrap_length)
space_prefix = message.match(/^\s*/)
message = Wrapper.wrap("#{CONTENT_COLOR_MAP[log.level]}#{message}", before_message(true, space_prefix),
wrap_length - space_prefix.length)
"#{CONTENT_COLOR_MAP[log.level]}#{message}#{color_map.clear}"
end
@ -88,11 +90,11 @@ class BasicFormatter < SemanticLogger::Formatters::Color
private
def before_message(wrapped = false)
def before_message(wrapped = false, prefix = '')
result = [name, level, tags, named_tags, duration, CONTENT_PREFIX].compact.join(' ')
if wrapped
[name, level, tags, named_tags, duration,
"#{color}#{WRAP_PREFIX}#{color_map.clear}"].compact.join(' ')
"#{color}#{WRAP_PREFIX}#{color_map.clear}#{prefix}"].compact.join(' ')
else
[name, level, tags, named_tags, duration,
CONTENT_PREFIX].compact.join(' ')

Loading…
Cancel
Save