Module: Awetestlib::Logging

Included in:
Regression::Runner
Defined in:
lib/awetestlib/logging.rb

Overview

Logging and reporting.

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(mod) ⇒ Object

Deprecated.


6
7
8
# File 'lib/awetestlib/logging.rb', line 6

def self.included(mod)
  # puts "RegressionSupport::Logging extended by #{mod}"
end

Instance Method Details

#debug_to_log(message, lnbr = nil, dbg = false) Also known as: debug_tolog

This method returns an undefined value.

Parameters:

  • message (String)

    The text to place in the log and report



151
152
153
154
# File 'lib/awetestlib/logging.rb', line 151

def debug_to_log(message, lnbr = nil, dbg = false)
  message << "\n#{get_debug_list}" if dbg or @debug_calls # and not @debug_calls_fail_only)
  log_message(DEBUG, "#{message}", nil, lnbr)
end

#debug_to_report(message, dbg = false)

This method returns an undefined value.

Parameters:

  • message (String)

    The text to place in the log and report



220
221
222
# File 'lib/awetestlib/logging.rb', line 220

def debug_to_report(message, dbg = false)
  mark_testlevel("(DEBUG): ", 0, "#{message}", dbg)
end

#error_to_log(message, lnbr = nil) Also known as: error_tolog

Note:

Do not use for failed validations. Use only for serious error conditions.

This method returns an undefined value.

Parameters:

  • message (String)

    The text to place in the log and report



161
162
163
# File 'lib/awetestlib/logging.rb', line 161

def error_to_log(message, lnbr = nil)
  log_message(ERROR, message, nil, lnbr)
end

#failed_to_log(message, lnbr = nil, dbg = false, exception = nil) Also known as: validate_failed_tolog, validate_failed_to_log, failed_tolog, fail_tolog, fail_to_log

This method returns an undefined value.

Parameters:

  • message (String)

    The text to place in the log and report



185
186
187
188
189
190
191
# File 'lib/awetestlib/logging.rb', line 185

def failed_to_log(message, lnbr = nil, dbg = false, exception = nil)
  message << " \n#{get_debug_list}" if dbg.to_s == 'true' or @debug_calls or @debug_calls_fail_only
  @my_failed_count += 1 if @my_failed_count
  parse_error_references(message, true)
  @report_class.add_to_report("#{message}" + " [#{get_caller(lnbr)}]", "FAILED") unless Awetestlib::Runner.nil?
  log_message(WARN, "#{message}", FAIL, lnbr, nil, exception)
end

#fatal_to_log(message, lnbr = nil, dbg = false, exception = nil) Also known as: fatal_tolog

This method returns an undefined value.

Parameters:

  • message (String)

    The text to place in the log and report



201
202
203
204
205
206
207
208
# File 'lib/awetestlib/logging.rb', line 201

def fatal_to_log(message, lnbr = nil, dbg = false, exception = nil)
  message << " \n#{get_debug_list}" if dbg.to_s == 'true' or (@debug_calls and not @debug_calls_fail_only)
  @my_failed_count += 1 if @my_failed_count
  parse_error_references(message, true)
  @report_class.add_to_report("#{message}" + " [#{get_caller(lnbr)}]", "FAILED") unless Awetestlib::Runner.nil?
  debug_to_report("#{__method__}:\n#{dump_caller(lnbr)}")
  log_message(FATAL, "#{message} (#{lnbr})", FAIL, lnbr, nil, exception)
end

#info_to_log(message, lnbr = nil) Also known as: message_tolog, message_to_log, info_tolog

This method returns an undefined value.

Parameters:

  • message (String)

    The text to place in the log



141
142
143
# File 'lib/awetestlib/logging.rb', line 141

def info_to_log(message, lnbr = nil)
  log_message(INFO, message, 0, lnbr)
end

#mark_test_level(message = '', lvl = nil, desc = '', dbg = nil) Also known as: mark_testlevel

This method returns an undefined value.

Write a status message to the log and report indicating location or activity in the script. mark_test_level automatically determines the call hierarchy level of the calling method within the script and project utility methods. The top level method of the script is always level 1. The method also prefixes the calling method name (titleized) to the message to be placed in the log. calling method name. attached. Any other integer is ignored in favor of the calculated level

Parameters:

  • message (String) (defaults to: '')

    The text to place in the log and report after the titleized

  • lvl (Fixnum) (defaults to: nil)

    ‘0’ forces a message to the report without a specific level

  • desc (String) (defaults to: '')

    Any additional information to add to the message.

  • dbg (Boolean) (defaults to: nil)

    When set to true adds a trace to the message.



118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
# File 'lib/awetestlib/logging.rb', line 118

def mark_test_level(message = '', lvl = nil, desc = '', dbg = nil)
  call_arr = get_call_array()
  #debug_to_log("#{call_arr.to_yaml}")
  strg = ''
  call_script, call_line, call_meth = parse_caller(call_arr[1])
  if not lvl or lvl > 1
    lvl, list = get_test_level
    strg << "#{call_meth.titleize}"
  end
  strg << " #{message}" if message.length > 0
  strg << " (#{desc})" if desc.length > 0
  strg << " [#{call_line}]"
  strg << "\n#{list.to_yaml}" if dbg or @debug_calls
  @report_class.add_to_report(strg, "&nbsp", lvl || 1) unless Awetestlib::Runner.nil?
  log_message(INFO, strg, lvl, nil, 1)
rescue
  failed_to_log("#{__method__}: #{$!}")
end

#message_to_report(message, dbg = false)

This method returns an undefined value.

Parameters:

  • message (String)

    The text to place in the log and report



214
215
216
# File 'lib/awetestlib/logging.rb', line 214

def message_to_report(message, dbg = false)
  mark_testlevel(message, 0, '', dbg)
end

#passed_to_log(message, lnbr = nil, dbg = false) Also known as: validate_passed_tolog, validate_passed_to_log, passed_tolog, pass_tolog, pass_to_log

This method returns an undefined value.

Parameters:

  • message (String)

    The text to place in the log and report



169
170
171
172
173
174
175
# File 'lib/awetestlib/logging.rb', line 169

def passed_to_log(message, lnbr = nil, dbg = false)
  message << " \n#{get_debug_list}" if dbg or @debug_calls # and not @debug_calls_fail_only)
  @my_passed_count += 1 if @my_passed_count
  parse_error_references(message)
  @report_class.add_to_report(message, "PASSED") unless Awetestlib::Runner.nil?
  log_message(INFO, "#{message}", PASS, lnbr)
end