Commit 22c21ade authored by Andrejs Cunskis's avatar Andrejs Cunskis Committed by Tiffany Rea

E2E: Add specific colors for every log level

parent 1c553a0d
......@@ -11,6 +11,12 @@ require_relative 'lib/gitlab'
require_relative '../config/bundler_setup'
Bundler.require(:default)
require 'securerandom'
require 'pathname'
require 'active_support/core_ext/hash'
require 'active_support/core_ext/object/blank'
require 'rainbow/refinement'
module QA
root = "#{__dir__}/qa"
......
......@@ -2,13 +2,19 @@
require 'logger'
require 'forwardable'
require 'rainbow/refinement'
module QA
module Runtime
module Logger
extend SingleForwardable
using Rainbow
LEVEL_COLORS = {
"DEBUG" => :magenta,
"INFO" => :green,
"WARN" => :yellow,
"ERROR" => :indianred,
"FATAL" => :red
}.freeze
def_delegators :logger, :debug, :info, :warn, :error, :fatal, :unknown
......@@ -23,8 +29,9 @@ module QA
logger.formatter = proc do |severity, datetime, progname, msg|
date_format = datetime.strftime("%Y-%m-%d %H:%M:%S")
msg_prefix = "[date=#{date_format} from=QA Tests] #{severity.ljust(5)} -- "
"[date=#{date_format} from=QA Tests] #{severity.ljust(5)} -- ".yellow + "#{msg}\n"
Rainbow(msg_prefix).send(LEVEL_COLORS.fetch(severity, :yellow)) + "#{msg}\n"
end
end
end
......
# frozen_string_literal: true
require 'active_support/inflector'
require 'rainbow/refinement'
module QA
module Support
......@@ -40,7 +39,9 @@ module QA
QA::Runtime::Logger.debug(msg.join(' '))
end
QA::Runtime::Logger.debug("Attempt number #{attempts + 1}".bg(:yellow).black) if log && max_attempts && attempts > 0
if log && max_attempts && attempts > 0
QA::Runtime::Logger.debug("Attempt number #{attempts + 1}".bg(:yellow).black)
end
result = yield
if result
......
......@@ -2,12 +2,6 @@
require_relative '../qa'
require 'securerandom'
require 'pathname'
require 'active_support/core_ext/hash'
require 'active_support/core_ext/object/blank'
require 'rainbow/refinement'
require_relative 'qa_deprecation_toolkit_env'
QaDeprecationToolkitEnv.configure!
......@@ -36,7 +30,7 @@ RSpec.configure do |config|
end
config.prepend_before do |example|
QA::Runtime::Logger.debug("\nStarting test: #{example.full_description}\n")
QA::Runtime::Logger.info("Starting test: #{Rainbow(example.full_description).bright}")
QA::Runtime::Example.current = example
# Reset fabrication counters tracked in resource base
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment