Skip to content

Commit

Permalink
log level updates (#17)
Browse files Browse the repository at this point in the history
* add UNKNOWN log level
* allow `:passed`, `:failed`, `:undefined`, `:pending`, `:skipped` aliases that were used by some formatters
  • Loading branch information
monkey-t authored and abotalov committed Jan 10, 2018
1 parent 0cf80b3 commit 8d1ee62
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions lib/reportportal.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

module ReportPortal
TestItem = Struct.new(:name, :type, :id, :start_time, :description, :closed, :tags)
LOG_LEVELS = { error: 'ERROR', warn: 'WARN', info: 'INFO', debug: 'DEBUG', trace: 'TRACE', unknown: 'UNKNOWN' } # TODO: remove unknown as it's not listed and it's strange to have such log level
LOG_LEVELS = { error: 'ERROR', warn: 'WARN', info: 'INFO', debug: 'DEBUG', trace: 'TRACE', fatal: 'FATAL', unknown: 'UNKNOWN' }

@response_handler = proc do |response, request, result, &block|
if (200..207).include? response.code
Expand All @@ -48,17 +48,16 @@ def now
end

def status_to_level(status)
LOG_LEVELS.fetch(status)
# case status
# when :failed, :undefined, :pending
# LOG_LEVELS[:error]
# when :skipped
# LOG_LEVELS[:warn]
# when :passed
# LOG_LEVELS[:info]
# else
# LOG_LEVELS.values.include?(status) ? status : LOG_LEVELS[:unknown]
# end
case status
when :passed
LOG_LEVELS[:info]
when :failed, :undefined, :pending, :error
LOG_LEVELS[:error]
when :skipped
LOG_LEVELS[:warn]
else
LOG_LEVELS.fetch(status, LOG_LEVELS.fetch[:info])
end
end

def start_launch(description, start_time = now)
Expand Down

0 comments on commit 8d1ee62

Please sign in to comment.