Class: PredictabilityEngine::TerminalFormatter

Inherits:
SemanticLogger::Formatters::Base
  • Object
show all
Defined in:
lib/predictability_engine/logger.rb

Overview

Custom console formatter matching current terminal output:

INFO   plain message (no prefix)
WARN   yellow "Warning: …"
ERROR  red    "Error: …"
DEBUG  gray   "DEBUG: …"

Instance Method Summary collapse

Instance Method Details

#call(log, _logger) ⇒ Object



13
14
15
16
17
18
19
20
21
# File 'lib/predictability_engine/logger.rb', line 13

def call(log, _logger)
  msg = log.message.to_s
  case log.level
  when :error then "\e[31mError: #{msg}\e[0m\n"
  when :warn  then "\e[33mWarning: #{msg}\e[0m\n"
  when :debug then "\e[90mDEBUG: #{msg}\e[0m\n"
  else "#{msg}\n"
  end
end