diff --git a/app/controllers/scores_controller.rb b/app/controllers/scores_controller.rb index bf6c99a..5ff2bf7 100644 --- a/app/controllers/scores_controller.rb +++ b/app/controllers/scores_controller.rb @@ -32,16 +32,16 @@ class ScoresController < ApplicationController logger.info(BG_WHITE + TEXT_GRAY_200 + "this is #{BOLD}a message in bold#{CLEAR}, isnt'it?") logger.info(BG_WHITE + TEXT_GRAY_100 + "this is #{BOLD}a message in bold#{CLEAR}, isnt'it?") - # logger.info({ one: 1, two: 2 }) - # logger.info 'this is an information', { four: 4, five: 5 } + logger.info({ one: 1, two: 2 }) + logger.info 'this is an information', { four: 4, five: 5 } logger.debug BigDecimal('0.0003') - # logger.warn 'scores are', @scores + logger.warn 'scores are', @scores logger.warn "this is a #{BOLD}warning#{CLEAR}#{BG_YELLOW}#{TEXT_BLACK}\n yop\n cool" logger.warn "this is a warning\n yop\n cool" logger.error 'this is an error message' - # logger.error "error message line #1\nerror message line #2\nerror message line #3\n\n" - # logger.info 'end of normal message' - # logger.debug @scores + logger.error "error message line #1\nerror message line #2\nerror message line #3\n\n" + logger.info 'end of normal message' + logger.debug @scores # sleep 0.5 end diff --git a/config/database.yml b/config/database.yml index 6687bed..2334a0c 100644 --- a/config/database.yml +++ b/config/database.yml @@ -6,7 +6,7 @@ default: &default # For details on connection pooling, see Rails configuration guide # https://guides.rubyonrails.org/configuring.html#database-pooling pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %> - host: localhost + host: ct1.lxd development: <<: *default diff --git a/lib/formatters/ansi_formatter.rb b/lib/formatters/ansi_formatter.rb index b1f9a82..808d6b4 100644 --- a/lib/formatters/ansi_formatter.rb +++ b/lib/formatters/ansi_formatter.rb @@ -15,6 +15,8 @@ class AnsiFormatter < SemanticLogger::Formatters::Color ANSI_ERROR = CLEAR + BG_RED + TEXT_WHITE ANSI_FATAL = CLEAR + BG_MAGENTA + BOLD + TEXT_WHITE NAME_MAX_SIZE = 20 + FOREMAN_PREFIX_LENGTH = 18 + DEFAULT_UNDETECTED_WRAP = 80 def initialize super(color_map: ColorMap.new( @@ -30,7 +32,8 @@ class AnsiFormatter < SemanticLogger::Formatters::Color self.log = log self.logger = logger self.color = color_map[log.level] - wrap_level(level, message, payload, exception) + wrap_length = compute_useful_length + wrap_level(level, wrap_length, message, payload, exception) end def origin @@ -56,6 +59,12 @@ class AnsiFormatter < SemanticLogger::Formatters::Color private + def compute_useful_length + IO.console.winsize[1] - FOREMAN_PREFIX_LENGTH + rescue StandardError + DEFAULT_UNDETECTED_WRAP + end + def clean_backtrace(backtrace) root_path = Rails.root.to_s backtrace = backtrace.select { |line| line.starts_with?(root_path) } @@ -67,11 +76,11 @@ class AnsiFormatter < SemanticLogger::Formatters::Color "#{tint}#{text}#{AnsiColors::CLEAR}" end - def wrap_level(level, *items) + def wrap_level(level, length, *items) prefix = "#{origin} #{colorize('>')} " continuation = "#{origin} #{colorize('#')} " items.map do |item| - AnsiWrapper.wrap(item, 100, prefix, continuation) + AnsiWrapper.wrap(item, length, prefix, continuation) end.compact.join("\n") # FIXME: previously was: join(' ') end end