|
@ -1,7 +1,6 @@ |
|
|
require_relative 'ansi_wrapper' |
|
|
require_relative 'ansi_wrapper' |
|
|
require_relative 'ansi_colors' |
|
|
require_relative 'ansi_colors' |
|
|
require_relative 'ansi_dimensions' |
|
|
require_relative 'ansi_dimensions' |
|
|
require_relative 'ansi_common' |
|
|
|
|
|
|
|
|
|
|
|
require 'io/console' |
|
|
require 'io/console' |
|
|
require 'amazing_print' |
|
|
require 'amazing_print' |
|
@ -49,6 +48,14 @@ class AnsiFormatter < SemanticLogger::Formatters::Color |
|
|
|
|
|
|
|
|
private |
|
|
private |
|
|
|
|
|
|
|
|
|
|
|
def ansi_trace(trace, symbol) |
|
|
|
|
|
match = trace.match(/(↳ )?(.*:\d+)(:in `)?(.*'?)/) # only m2(=file) and m4(=optional function) are useful |
|
|
|
|
|
return trace unless match |
|
|
|
|
|
|
|
|
|
|
|
_, m2, _, m4 = match.captures |
|
|
|
|
|
"#{symbol} #{m2} #{BOLD}#{m4.chop}#{CLEAR}" |
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
def two_captures_last_as_bold(message, regex) |
|
|
def two_captures_last_as_bold(message, regex) |
|
|
match = message.match(regex) |
|
|
match = message.match(regex) |
|
|
return "unmatched: #{message}" unless match |
|
|
return "unmatched: #{message}" unless match |
|
@ -122,13 +129,13 @@ class AnsiFormatter < SemanticLogger::Formatters::Color |
|
|
unbold!(log.message) |
|
|
unbold!(log.message) |
|
|
|
|
|
|
|
|
if log.message.starts_with?('↳ ') |
|
|
if log.message.starts_with?('↳ ') |
|
|
log.message = AnsiCommon.ansi_trace(log.message, '⇄') |
|
|
|
|
|
|
|
|
log.message = ansi_trace(log.message, '⇄') |
|
|
else |
|
|
else |
|
|
sql_match = log.message.match(/\s+\[\[.*\]\]$/) |
|
|
sql_match = log.message.match(/\s+\[\[.*\]\]$/) |
|
|
if sql_match |
|
|
if sql_match |
|
|
sql_command = sql_match.pre_match |
|
|
sql_command = sql_match.pre_match |
|
|
sql_type, sql_entry = sql_command.split("\e[0m") |
|
|
sql_type, sql_entry = sql_command.split("\e[0m") |
|
|
sql_color_entry = sql_entry.match(AnsiCommon::ANSI_REGEX).to_s |
|
|
|
|
|
|
|
|
sql_color_entry = sql_entry.match(ANSI_REGEX).to_s |
|
|
sql_args = JSON.parse(sql_match.to_s).map(&:last) |
|
|
sql_args = JSON.parse(sql_match.to_s).map(&:last) |
|
|
sql_args.each_with_index do |val, index| |
|
|
sql_args.each_with_index do |val, index| |
|
|
sql_arg = val.inspect |
|
|
sql_arg = val.inspect |
|
@ -154,7 +161,7 @@ class AnsiFormatter < SemanticLogger::Formatters::Color |
|
|
end |
|
|
end |
|
|
|
|
|
|
|
|
def draw_fatal(char = CHAR_FATAL) |
|
|
def draw_fatal(char = CHAR_FATAL) |
|
|
AnsiColors::BG_MAGENTA + AnsiColors::BOLD + AnsiColors::TEXT_WHITE + char + AnsiColors::CLEAR |
|
|
|
|
|
|
|
|
BG_MAGENTA + BOLD + TEXT_WHITE + char + CLEAR |
|
|
end |
|
|
end |
|
|
|
|
|
|
|
|
def origin = colorize(centerize(log.name), TEXT_CYAN) |
|
|
def origin = colorize(centerize(log.name), TEXT_CYAN) |
|
@ -166,7 +173,7 @@ class AnsiFormatter < SemanticLogger::Formatters::Color |
|
|
def stackisize(items) |
|
|
def stackisize(items) |
|
|
return '' if items.empty? |
|
|
return '' if items.empty? |
|
|
|
|
|
|
|
|
traces = items.map { |item| AnsiCommon.ansi_trace(item, '➟') } |
|
|
|
|
|
|
|
|
traces = items.map { |item| ansi_trace(item, '➟') } |
|
|
"\n#{traces.join("\n")}" |
|
|
"\n#{traces.join("\n")}" |
|
|
end |
|
|
end |
|
|
|
|
|
|
|
|