|
@ -9,6 +9,8 @@ class BasicFormatter < SemanticLogger::Formatters::Color # rubocop:disable Metri |
|
|
TERMINAL_PREFIX = ENV['TERMINAL_PREFIX'].to_i || 0 |
|
|
TERMINAL_PREFIX = ENV['TERMINAL_PREFIX'].to_i || 0 |
|
|
CONTENT_PREFIX = ' '.freeze |
|
|
CONTENT_PREFIX = ' '.freeze |
|
|
|
|
|
|
|
|
|
|
|
RENDERED_VIEW_DURATION = 100 |
|
|
|
|
|
|
|
|
ANSI_DEBUG = "\e[90m".freeze |
|
|
ANSI_DEBUG = "\e[90m".freeze |
|
|
ANSI_INFO = SemanticLogger::AnsiColors::GREEN |
|
|
ANSI_INFO = SemanticLogger::AnsiColors::GREEN |
|
|
ANSI_WARN = SemanticLogger::AnsiColors::YELLOW |
|
|
ANSI_WARN = SemanticLogger::AnsiColors::YELLOW |
|
@ -46,7 +48,6 @@ 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 |
|
@ -77,14 +78,6 @@ class BasicFormatter < SemanticLogger::Formatters::Color # rubocop:disable Metri |
|
|
end |
|
|
end |
|
|
end |
|
|
end |
|
|
|
|
|
|
|
|
def draw_rails(char) |
|
|
|
|
|
"#{color}╣#{char}╠#{color_map.clear}" |
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
def continuation |
|
|
|
|
|
draw_rails('┆') |
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
def name |
|
|
def name |
|
|
"#{ANSI_DEBUG}#{log.name.truncate(NAME_MAX_SIZE).center(NAME_MAX_SIZE)}#{color_map.clear}" |
|
|
"#{ANSI_DEBUG}#{log.name.truncate(NAME_MAX_SIZE).center(NAME_MAX_SIZE)}#{color_map.clear}" |
|
|
end |
|
|
end |
|
@ -109,10 +102,17 @@ class BasicFormatter < SemanticLogger::Formatters::Color # rubocop:disable Metri |
|
|
|
|
|
|
|
|
private |
|
|
private |
|
|
|
|
|
|
|
|
|
|
|
def draw_rails(char) |
|
|
|
|
|
"#{color}╣#{char}╠#{color_map.clear}" |
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
def continuation |
|
|
|
|
|
draw_rails('┆') |
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
def transform_log(log) |
|
|
def transform_log(log) |
|
|
if log.name == 'ActionView::Base' |
|
|
if log.name == 'ActionView::Base' |
|
|
log.level = :debug |
|
|
|
|
|
log.message = log.message.lstrip |
|
|
|
|
|
|
|
|
log = transform_action_view_base(log) |
|
|
elsif log.name == 'Rails' && log.message |
|
|
elsif log.name == 'Rails' && log.message |
|
|
message = log.message.rstrip |
|
|
message = log.message.rstrip |
|
|
message += "\n" if message.starts_with?('Completed 2') || message.starts_with?('Completed 3') |
|
|
message += "\n" if message.starts_with?('Completed 2') || message.starts_with?('Completed 3') |
|
@ -121,6 +121,31 @@ class BasicFormatter < SemanticLogger::Formatters::Color # rubocop:disable Metri |
|
|
log |
|
|
log |
|
|
end |
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
def transform_action_view_base(log) |
|
|
|
|
|
log.level, message = transform_log_debug_lstrip(log) |
|
|
|
|
|
message = transform_rendered_message_with_filename(message) |
|
|
|
|
|
message = transform_duration_strip(message) |
|
|
|
|
|
log.message = message |
|
|
|
|
|
log |
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
def transform_duration_strip(message) |
|
|
|
|
|
md2 = message.match(/( \(Duration: \d+\.?\d?ms.*\))/) |
|
|
|
|
|
md3 = md2.match(1).match(/Duration: (\d+\.?\d?)ms/) |
|
|
|
|
|
duration = md3.match(1).to_f |
|
|
|
|
|
duration < RENDERED_VIEW_DURATION ? md2.pre_match : message |
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
def transform_rendered_message_with_filename(message) |
|
|
|
|
|
md = message.match(/^Rendered( layout| collection of|) (.*?\.erb)/) |
|
|
|
|
|
filename = "app/views/#{md.match(2)}" |
|
|
|
|
|
log.message = "Rendered#{md.match(1)} #{filename}#{md.post_match}" |
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
def transform_log_debug_lstrip(log) |
|
|
|
|
|
[:debug, log.message.lstrip] |
|
|
|
|
|
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}", |
|
|