class TeamCityFormatter::Logger
Public Class Methods
new(io)
click to toggle source
# File lib/team_city_formatter/logger.rb, line 3 def initialize(io) @io = io end
Public Instance Methods
test_failed(test_name, details)
click to toggle source
# File lib/team_city_formatter/logger.rb, line 24 def test_failed(test_name, details) render_output("##teamcity[testFailed flowId='#{flow_id}' name='#{teamcity_escape(test_name)}' message='#{teamcity_escape(details)}' timestamp='#{timestamp}']") end
test_failed_with_exception(test_name, exception)
click to toggle source
# File lib/team_city_formatter/logger.rb, line 19 def test_failed_with_exception(test_name, exception) details = format_exception(exception) test_failed(test_name, details) end
test_finished(test_name)
click to toggle source
# File lib/team_city_formatter/logger.rb, line 32 def test_finished(test_name) render_output("##teamcity[testFinished flowId='#{flow_id}' name='#{teamcity_escape(test_name)}' timestamp='#{timestamp}']") end
test_ignored(test_name, details)
click to toggle source
# File lib/team_city_formatter/logger.rb, line 28 def test_ignored(test_name, details) render_output("##teamcity[testIgnored flowId='#{flow_id}' name='#{teamcity_escape(test_name)}' message='#{teamcity_escape(details)}' timestamp='#{timestamp}']") end
test_started(test_name)
click to toggle source
# File lib/team_city_formatter/logger.rb, line 15 def test_started(test_name) render_output("##teamcity[testStarted flowId='#{flow_id}' name='#{teamcity_escape(test_name)}' captureStandardOutput='true' timestamp='#{timestamp}']") end
test_suite_finished(test_suite_name)
click to toggle source
# File lib/team_city_formatter/logger.rb, line 11 def test_suite_finished(test_suite_name) render_output("##teamcity[testSuiteFinished flowId='#{flow_id}' name='#{teamcity_escape(test_suite_name)}' timestamp='#{timestamp}']") end
test_suite_started(test_suite_name)
click to toggle source
# File lib/team_city_formatter/logger.rb, line 7 def test_suite_started(test_suite_name) render_output("##teamcity[testSuiteStarted flowId='#{flow_id}' name='#{teamcity_escape(test_suite_name)}' timestamp='#{timestamp}']") end
Private Instance Methods
flow_id()
click to toggle source
# File lib/team_city_formatter/logger.rb, line 69 def flow_id Process.pid end
format_exception(exception)
click to toggle source
# File lib/team_city_formatter/logger.rb, line 64 def format_exception(exception) lines = ["#{exception.message} (#{exception.class})"] + exception.backtrace lines.join("\n") end
render_output(text)
click to toggle source
# File lib/team_city_formatter/logger.rb, line 38 def render_output(text) @io.puts(text) @io.flush end
teamcity_escape(s)
click to toggle source
# File lib/team_city_formatter/logger.rb, line 43 def teamcity_escape(s) s.to_s.strip .gsub(':', ' -') .gsub('|', '||') .gsub("'", "|'") .gsub(']', '|]') .gsub('[', '|[') .gsub("\r", '|r') .gsub("\n", '|n') end
timestamp()
click to toggle source
# File lib/team_city_formatter/logger.rb, line 59 def timestamp now = Time.now '%s.%0.3d' % [now.strftime('%Y-%m-%dT%H:%M:%S'), (now.usec / 1000)] end
timestamp_short()
click to toggle source
# File lib/team_city_formatter/logger.rb, line 54 def timestamp_short now = Time.now '%s.%0.3d' % [now.strftime('%H:%M:%S'), (now.usec / 1000)] end