pvincent
7 months ago
1 changed files with 28 additions and 16 deletions
@ -1,32 +1,44 @@ |
|||
require_relative 'ansi_dimensions' |
|||
require_relative 'ansi_colors' |
|||
|
|||
# filter log message |
|||
module AnsiFilter |
|||
$memory = nil |
|||
|
|||
CHAR_FATAL = '⯶'.freeze |
|||
|
|||
def self.reject(log) |
|||
# log.name == 'ScoresController' || false |
|||
false |
|||
end |
|||
|
|||
def self.alter(log) |
|||
if log.name == 'Rails' && log.message |
|||
log.message.chomp!('') |
|||
if log.message.starts_with?('Started') |
|||
rails = '╓─╖' |
|||
rails = "╓#{$memory}╖" if $memory |
|||
log.dimensions = AnsiDimensions.new(rails:) |
|||
$memory = nil |
|||
elsif log.message.starts_with?('Completed 2') |
|||
log.dimensions = AnsiDimensions.new(rails: '╙─╜', after: 2) |
|||
elsif log.message.starts_with?('Completed 3') |
|||
$memory = '║' |
|||
log.dimensions = AnsiDimensions.new(rails: "╙#{$memory}╜") |
|||
elsif log.message.starts_with?('Completed 4') |
|||
log.dimensions = AnsiDimensions.new(rails: '╙╨╜') |
|||
elsif log.message.starts_with?('Completed 5') |
|||
log.dimensions = AnsiDimensions.new(rails: '╙⯶╜') |
|||
if log.name == 'Rails' |
|||
if log.message |
|||
log.message.chomp!('') |
|||
if log.message.starts_with?('Started') |
|||
rails = '╓─╖' |
|||
rails = "╓#{$memory}╖" if $memory |
|||
log.dimensions = AnsiDimensions.new(rails:) |
|||
$memory = nil |
|||
elsif log.message.starts_with?('Completed 2') |
|||
log.dimensions = AnsiDimensions.new(rails: '╙─╜', after: 2) |
|||
elsif log.message.starts_with?('Completed 3') |
|||
$memory = '║' |
|||
log.dimensions = AnsiDimensions.new(rails: "╙#{$memory}╜") |
|||
elsif log.message.starts_with?('Completed 4') |
|||
log.dimensions = AnsiDimensions.new(rails: '╙╨╜') |
|||
elsif log.message.starts_with?('Completed 5') |
|||
log.dimensions = AnsiDimensions.new(rails: "╙#{draw_fatal}╜") |
|||
end |
|||
elsif log.exception |
|||
log.dimensions = AnsiDimensions.new(rails: "╓#{draw_fatal(log.level.to_s.chr.upcase)}╖", after: 2) |
|||
end |
|||
end |
|||
log |
|||
end |
|||
|
|||
private_class_method def self.draw_fatal(char = CHAR_FATAL) |
|||
AnsiColors::BG_MAGENTA + AnsiColors::BOLD + AnsiColors::TEXT_WHITE + char + AnsiColors::CLEAR |
|||
end |
|||
end |
Write
Preview
Loading…
Cancel
Save
Reference in new issue