pvincent
6 months ago
3 changed files with 54 additions and 59 deletions
-
8config/environments/development.rb
-
53lib/formatters/ansi_filter.rb
-
52lib/formatters/ansi_formatter.rb
@ -1,53 +0,0 @@ |
|||||
require_relative 'ansi_dimensions' |
|
||||
require_relative 'ansi_colors' |
|
||||
|
|
||||
# filter log message |
|
||||
module AnsiFilter |
|
||||
$memory = nil |
|
||||
|
|
||||
CHAR_FATAL = '⯶'.freeze |
|
||||
TERMINUS_STRING = '╙─╜'.freeze |
|
||||
|
|
||||
def self.reject(log) |
|
||||
# log.name == 'ScoresController' || false |
|
||||
false |
|
||||
end |
|
||||
|
|
||||
def self.alter(log) |
|
||||
if log.name == 'Rails' |
|
||||
if log.message |
|
||||
log.message.chomp!('') |
|
||||
if log.message.starts_with?('Started') |
|
||||
rails = '╓─╖' |
|
||||
before = 1 |
|
||||
if $memory |
|
||||
rails = "╓#{$memory}╖" |
|
||||
before = 0 |
|
||||
end |
|
||||
log.dimensions = AnsiDimensions.new(rails:, before:) |
|
||||
$memory = nil |
|
||||
elsif log.message.starts_with?('Completed 2') |
|
||||
log.dimensions = AnsiDimensions.new(rails: TERMINUS_STRING, after: 1) |
|
||||
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: 1, |
|
||||
terminus: true |
|
||||
) |
|
||||
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