Browse Source

debug downcase

pagy
pvincent 10 months ago
parent
commit
8b4824b21c
  1. 6
      app/controllers/scores_controller.rb
  2. 8
      lib/formatters/basic_formatter.rb

6
app/controllers/scores_controller.rb

@ -7,10 +7,10 @@ class ScoresController < ApplicationController
@scores = Score.all @scores = Score.all
logger.info 'this is an information', { 'one': 1, 'two': 2 } logger.info 'this is an information', { 'one': 1, 'two': 2 }
logger.info 'this is an object', BigDecimal('0.0001') logger.info 'this is an object', BigDecimal('0.0001')
# logger.warn 'this is a warning'
# logger.error 'this is an error'
# logger.debug 'this is a debug message' # logger.debug 'this is a debug message'
# logger.fatal 'FATAL'
logger.warn 'this is a warning'
logger.error 'this is an error', BigDecimal('0.0002')
logger.fatal 'FATAL'
logger.debug 'score are', @scores logger.debug 'score are', @scores
end end

8
lib/formatters/basic_formatter.rb

@ -8,7 +8,7 @@ class BasicFormatter < SemanticLogger::Formatters::Color
NAME_MAX_SIZE = 25 NAME_MAX_SIZE = 25
TERMINAL_PREFIX = ENV['TERMINAL_PREFIX'].to_i || 0 TERMINAL_PREFIX = ENV['TERMINAL_PREFIX'].to_i || 0
CONTENT_PREFIX = ' '.freeze CONTENT_PREFIX = ' '.freeze
WRAP_PREFIX = ' > '.freeze
WRAP_PREFIX = ' '.freeze
ANSI_DEBUG = "\e[90m".freeze ANSI_DEBUG = "\e[90m".freeze
ANSI_INFO = SemanticLogger::AnsiColors::GREEN ANSI_INFO = SemanticLogger::AnsiColors::GREEN
@ -77,7 +77,11 @@ class BasicFormatter < SemanticLogger::Formatters::Color
end end
def level def level
level = log.level == :info ? ' ' : log.level.to_s.chr.upcase
level = case log.level
when :info then ' '
when :debug then 'd'
else log.level.to_s.chr.upcase
end
"#{color}#{level}#{color_map.clear}" "#{color}#{level}#{color_map.clear}"
end end

Loading…
Cancel
Save