Module: TestProf::Logging

Overview

Helper for output printing

Constant Summary collapse

COLORS =
{
  info: "\e[34m", # blue
  warn: "\e[33m", # yellow
  error: "\e[31m", # red
}.freeze

Instance Method Summary collapse

Instance Method Details

#build_log_msg(level, msg) ⇒ Object



16
17
18
# File 'lib/test_prof/logging.rb', line 16

def build_log_msg(level, msg)
  colorize(level, "[TEST PROF #{level.to_s.upcase}] #{msg}")
end

#colorize(level, msg) ⇒ Object



20
21
22
23
24
# File 'lib/test_prof/logging.rb', line 20

def colorize(level, msg)
  return msg unless TestProf.config.color?

  "#{COLORS[level]}#{msg}\e[0m"
end

#log(level, msg) ⇒ Object



12
13
14
# File 'lib/test_prof/logging.rb', line 12

def log(level, msg)
  TestProf.config.output.puts(build_log_msg(level, msg))
end