Class: TmcDutLogger
Overview
The TmcDeviceLogger class manages logging for TMC devices
Instance Method Summary collapse
-
#debug(msg, args = {}) ⇒ Object
Public: Logs a debug message.
-
#duration(ms, args = {}) ⇒ Object
Public: Logs a duration message.
-
#error(msg, args = {}) ⇒ Object
Public: Logs an error message.
-
#info(msg, args = {}) ⇒ Object
Public: Logs an info message.
-
#initialize(dut, logger, test_case) ⇒ TmcDutLogger
constructor
Public: Initializes a DUT logger.
-
#keypress(key, args = {}) ⇒ Object
Public: Logs a key press.
-
#roi(roi, args = {}) ⇒ Object
Public: Logs an ROI.
-
#warn(msg, args = {}) ⇒ Object
Public: Logs a warning message.
Constructor Details
#initialize(dut, logger, test_case) ⇒ TmcDutLogger
Public: Initializes a DUT logger.
Returns nothing.
7 8 9 10 11 |
# File 'lib/logger/tmc_dut_logger.rb', line 7 def initialize(dut, logger, test_case) @dut = dut @logger = logger @test_case = test_case end |
Instance Method Details
#debug(msg, args = {}) ⇒ Object
Public: Logs a debug message.
msg - String debug message to log. screenshot - Boolean to capture and display a screenshot (default: false). use_last_image - Boolean to display the last captured image (default: false). screen_image - String path to image to display (default: nil). image_suffix - String suffix to use for new image capture (default: ”) attach - Boolean to attach the displayed image to ITMS/SWORD (default: false) attach_comment - String comment to associate with attached image, if attach is true (default: ‘Screenshot from TMC’) return_title - String Return Title to associate with attached image, if attach is true (default: nil)
Returns nothing.
25 26 27 |
# File 'lib/logger/tmc_dut_logger.rb', line 25 def debug(msg, args={}) do_log(:debug, msg, args) end |
#duration(ms, args = {}) ⇒ Object
Public: Logs a duration message.
ms - Integer duration in milliseconds to log. message - String custom duration message to log (default: ‘Time: N ms’). screenshot - Boolean to capture and display a screenshot (default: false). use_last_image - Boolean to display the last captured image (default: false). screen_image - String path to image to display (default: nil). attach - Boolean to attach the displayed image to ITMS/SWORD (default: false). attach_comment - String comment to associate with attached image, if attach is true (default: ‘Screenshot from TMC’). return_title - String Return Title to associate with attached image, if attach is true (default: nil).
Returns nothing.
142 143 144 145 |
# File 'lib/logger/tmc_dut_logger.rb', line 142 def duration(ms, args={}) msg = "#{args.fetch(:message, 'Duration')}: #{ms} ms" do_log(:info, msg, args.merge(tag: 'DURATION', info: ms.to_s)) end |
#error(msg, args = {}) ⇒ Object
Public: Logs an error message.
msg - String error message to log. screenshot - Boolean to capture and display a screenshot (default: true). use_last_image - Boolean to display the last captured image (default: false). screen_image - String path to image to display (default: nil). image_suffix - String suffix to use for new image capture (default: ”) attach - Boolean to attach the displayed image to ITMS/SWORD (default: false) attach_comment - String comment to associate with attached image, if attach is true (default: ‘Screenshot from TMC’) return_title - String Return Title to associate with attached image, if attach is true (default: nil)
Returns nothing.
73 74 75 76 77 78 79 80 |
# File 'lib/logger/tmc_dut_logger.rb', line 73 def error(msg, args={}) args[:screenshot] = args.fetch(:screenshot, true) if msg.is_a?(Exception) # "hidden" functionality to log an exception msg = "#{msg.}\n\t#{msg.backtrace.join("\t\n")}" end do_log(:error, msg, args) end |
#info(msg, args = {}) ⇒ Object
Public: Logs an info message.
msg - String info message to log. screenshot - Boolean to capture and display a screenshot (default: false). use_last_image - Boolean to display the last captured image (default: false). screen_image - String path to image to display (default: nil). image_suffix - String suffix to use for new image capture (default: ”) attach - Boolean to attach the displayed image to ITMS/SWORD (default: false) attach_comment - String comment to associate with attached image, if attach is true (default: ‘Screenshot from TMC’) return_title - String Return Title to associate with attached image, if attach is true (default: nil)
Returns nothing.
41 42 43 |
# File 'lib/logger/tmc_dut_logger.rb', line 41 def info(msg, args={}) do_log(:info, msg, args) end |
#keypress(key, args = {}) ⇒ Object
Public: Logs a key press.
key - String key to log. message - String custom ROI message to log (default: ‘Key Press’). screenshot - Boolean to capture and display a screenshot (default: false). use_last_image - Boolean to display the last captured image (default: false). screen_image - String path to image to display (default: nil). attach - Boolean to attach the displayed image to ITMS/SWORD (default: false). attach_comment - String comment to associate with attached image, if attach is true (default: ‘Screenshot from TMC’). return_title - String Return Title to associate with attached image, if attach is true (default: nil).
Returns nothing.
124 125 126 127 128 |
# File 'lib/logger/tmc_dut_logger.rb', line 124 def keypress(key, args={}) key = [key] unless key.is_a?(Array) msg = args.fetch(:message, 'Key Press') do_log(:info, msg, args.merge(tag: 'KEYPRESS', info: key.join(','), screenshot: true)) end |
#roi(roi, args = {}) ⇒ Object
Public: Logs an ROI.
roi_object - ROI object to log. message - String custom ROI message to log (default: ‘Region Of Interest’). screenshot - Boolean to capture and display a screenshot (default: true). use_last_image - Boolean to display the last captured image (default: false). screen_image - String path to image to display (default: nil). attach - Boolean to attach the displayed image to ITMS/SWORD (default: false). attach_comment - String comment to associate with attached image, if attach is true (default: ‘Screenshot from TMC’). return_title - String Return Title to associate with attached image, if attach is true (default: nil). expected_text - String expected text to log for Text ROIs (default: nil).
If default, the expected text associated with the ROI object will be used.
similarity - Integer similarity to log for all ROI types (default: nil).
If default, the threshold/level associated with the ROI object will be used.
Returns nothing.
98 99 100 101 102 103 104 105 106 107 108 109 110 |
# File 'lib/logger/tmc_dut_logger.rb', line 98 def roi(roi, args={}) msg = args.fetch(:message, 'Region Of Interest') # Capture new screenshot unless explicitly set false args[:screenshot] = args.fetch(:screenshot, true) args[:image1_rect] = [roi.x, roi.y, roi.width, roi.height] args[:image2] = roi.ref_img.empty? ? nil : roi.ref_img args[:image2_rect] = [roi.x, roi.y, roi.width, roi.height] if roi.is_a?(ImageRoi) && !roi.img_x.nil? args[:image2_rect] = [roi.img_x, roi.img_y, roi.img_width, roi.img_height] end info = "#{roi.class.name}#{roi.name.nil? ? '' : ':' + roi.name}" do_log(:info, msg, args.merge(tag: 'ROI', info: info)) end |
#warn(msg, args = {}) ⇒ Object
Public: Logs a warning message.
msg - String warning message to log. screenshot - Boolean to capture and display a screenshot (default: false). use_last_image - Boolean to display the last captured image (default: false). screen_image - String path to image to display (default: nil). image_suffix - String suffix to use for new image capture (default: ”) attach - Boolean to attach the displayed image to ITMS/SWORD (default: false) attach_comment - String comment to associate with attached image, if attach is true (default: ‘Screenshot from TMC’) return_title - String Return Title to associate with attached image, if attach is true (default: nil)
Returns nothing.
57 58 59 |
# File 'lib/logger/tmc_dut_logger.rb', line 57 def warn(msg, args={}) do_log(:warn, msg, args) end |