|
@ -4,7 +4,7 @@ require 'io/console' |
|
|
# Opinioned Rails custom formatter |
|
|
# Opinioned Rails custom formatter |
|
|
class BasicFormatter < SemanticLogger::Formatters::Color |
|
|
class BasicFormatter < SemanticLogger::Formatters::Color |
|
|
NAME_MAX_SIZE = 25 |
|
|
NAME_MAX_SIZE = 25 |
|
|
FOREMAN_PREFIX = 15 |
|
|
|
|
|
|
|
|
TERMINAL_PREFIX = ENV['TERMINAL_PREFIX'].to_i || 0 |
|
|
CONTENT_PREFIX = ' '.freeze |
|
|
CONTENT_PREFIX = ' '.freeze |
|
|
WRAP_PREFIX = ' > '.freeze |
|
|
WRAP_PREFIX = ' > '.freeze |
|
|
|
|
|
|
|
@ -54,7 +54,12 @@ class BasicFormatter < SemanticLogger::Formatters::Color |
|
|
message += "\n" unless message.starts_with?('Completed 5') |
|
|
message += "\n" unless message.starts_with?('Completed 5') |
|
|
end |
|
|
end |
|
|
|
|
|
|
|
|
wrap_length = IO.console.winsize[1] - FOREMAN_PREFIX - before_message.length + CONTENT_PREFIX.length + 12 |
|
|
|
|
|
|
|
|
begin |
|
|
|
|
|
wrap_length = IO.console.winsize[1] - TERMINAL_PREFIX - before_message.length + CONTENT_PREFIX.length + 12 |
|
|
|
|
|
rescue StandardError |
|
|
|
|
|
wrap_length = 100 |
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
space_prefix = message.match(/^\s*/) |
|
|
space_prefix = message.match(/^\s*/) |
|
|
message = Wrapper.wrap("#{CONTENT_COLOR_MAP[log.level]}#{message}", before_message(true, space_prefix), |
|
|
message = Wrapper.wrap("#{CONTENT_COLOR_MAP[log.level]}#{message}", before_message(true, space_prefix), |
|
|
wrap_length - space_prefix.length) |
|
|
wrap_length - space_prefix.length) |
|
|