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

new(options) click to toggle source

Constructs a new report logger instance.

Calls superclass method Bauxite::Loggers::NullLogger.new
# File lib/bauxite/core/logger.rb, line 116
def initialize(options)
        super(options)
        @data = []
end

Public Instance Methods

finalize(ctx) click to toggle source

Completes the log execution.

# File lib/bauxite/core/logger.rb, line 166
def finalize(ctx)
end
log(s, type = :info) click to toggle source

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
log_cmd(action) { ||| false| ... } click to toggle source

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