|
@ -46,13 +46,13 @@ class BasicFormatter < SemanticLogger::Formatters::Color # rubocop:disable Metri |
|
|
error: ANSI_ERROR, |
|
|
error: ANSI_ERROR, |
|
|
fatal: ANSI_ERROR |
|
|
fatal: ANSI_ERROR |
|
|
)) |
|
|
)) |
|
|
|
|
|
@caller = nil |
|
|
end |
|
|
end |
|
|
|
|
|
|
|
|
def message |
|
|
def message |
|
|
return unless log.message |
|
|
return unless log.message |
|
|
|
|
|
|
|
|
message = transform_message(log) |
|
|
|
|
|
message = wrap_message(message) |
|
|
|
|
|
|
|
|
message = wrap_message(log.message) |
|
|
"#{CONTENT_COLOR_MAP[log.level]}#{message}#{color_map.clear}" |
|
|
"#{CONTENT_COLOR_MAP[log.level]}#{message}#{color_map.clear}" |
|
|
end |
|
|
end |
|
|
|
|
|
|
|
@ -100,8 +100,8 @@ class BasicFormatter < SemanticLogger::Formatters::Color # rubocop:disable Metri |
|
|
end |
|
|
end |
|
|
|
|
|
|
|
|
def call(log, logger) |
|
|
def call(log, logger) |
|
|
self.color = color_map[log.level] |
|
|
|
|
|
self.log = log |
|
|
|
|
|
|
|
|
self.log = transform_log(log) |
|
|
|
|
|
self.color = color_map[self.log.level] |
|
|
self.logger = logger |
|
|
self.logger = logger |
|
|
|
|
|
|
|
|
before_message + [message, payload, exception].compact.join(' ') |
|
|
before_message + [message, payload, exception].compact.join(' ') |
|
@ -109,6 +109,18 @@ class BasicFormatter < SemanticLogger::Formatters::Color # rubocop:disable Metri |
|
|
|
|
|
|
|
|
private |
|
|
private |
|
|
|
|
|
|
|
|
|
|
|
def transform_log(log) |
|
|
|
|
|
if log.name == 'ActionView::Base' |
|
|
|
|
|
log.level = :debug |
|
|
|
|
|
log.message = log.message.lstrip |
|
|
|
|
|
elsif log.name == 'Rails' && log.message |
|
|
|
|
|
message = log.message.rstrip |
|
|
|
|
|
message += "\n" if message.starts_with?('Completed 2') || message.starts_with?('Completed 3') |
|
|
|
|
|
log.message = message |
|
|
|
|
|
end |
|
|
|
|
|
log |
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
def wrap_message(message) |
|
|
def wrap_message(message) |
|
|
message, space_prefix = split_spaces_in_front(message) |
|
|
message, space_prefix = split_spaces_in_front(message) |
|
|
message = Wrapper.wrap("#{CONTENT_COLOR_MAP[log.level]}#{message}", |
|
|
message = Wrapper.wrap("#{CONTENT_COLOR_MAP[log.level]}#{message}", |
|
@ -122,14 +134,6 @@ class BasicFormatter < SemanticLogger::Formatters::Color # rubocop:disable Metri |
|
|
[md.post_match, md.match(0)] |
|
|
[md.post_match, md.match(0)] |
|
|
end |
|
|
end |
|
|
|
|
|
|
|
|
def transform_message(log) |
|
|
|
|
|
return log.message unless log.name == 'Rails' && log.message.starts_with?('Completed') |
|
|
|
|
|
|
|
|
|
|
|
message = log.message.rstrip! |
|
|
|
|
|
message += "\n" unless message.starts_with?('Completed 5') |
|
|
|
|
|
message |
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
def compute_useful_length |
|
|
def compute_useful_length |
|
|
IO.console.winsize[1] - TERMINAL_PREFIX - before_message.length + CONTENT_PREFIX.length + 12 |
|
|
IO.console.winsize[1] - TERMINAL_PREFIX - before_message.length + CONTENT_PREFIX.length + 12 |
|
|
rescue StandardError |
|
|
rescue StandardError |
|
|