class Bauxite::Loggers::ReportLogger
Report logger.
This base logger class can be inherited to create reporting loggers.
Descendent classes must override the finalize method and iterate
the @data
array to produce the report.
The items included in the @data
array contain the following
fields:
- :name
-
Name of the current test.
- :actions
-
Array of actions with the following fields
-
:cmd
: name of the action. -
:args
: action arguments. -
:action
: action object. -
:status
: action execution status::ok
,:skip
or:error
. -
:capture
: path to the current capture, if any.
-
For an example of a ReportLogger implementation see the HtmlLogger class.
Public Class Methods
Constructs a new report logger instance.
# File lib/bauxite/core/logger.rb, line 116 def initialize(options) super(options) @data = [] end
Public Instance Methods
Completes the log execution.
# File lib/bauxite/core/logger.rb, line 166 def finalize(ctx) end
Logs the specified string.
type
, if specified, should be one of :error
,
:warning
, :info
(default), :debug
.
# File lib/bauxite/core/logger.rb, line 126 def log(s, type = :info) end
Echoes the raw action text.
# File lib/bauxite/core/logger.rb, line 130 def log_cmd(action) stime = Time.new ret = yield || false etime = Time.new ensure etime ||= Time.new status = case ret; when nil; :error; when false; :skip; else :ok; end test_name = action.ctx.variables['__TEST__'] || 'Main' test = @data.find { |t| t[:name] == test_name } unless test test = { :name => test_name, :actions => [] } @data << test end capture = action.ctx.variables['__CAPTURE__'] if capture == @last_capture capture = nil else @last_capture = capture end test[:actions] << { :cmd => action.cmd, :args => action.args(true), :action => action, :status => status, :time => (etime - stime), :capture => capture } ret end