Class: Bauxite::Loggers::ReportLogger
- Inherits:
-
NullLogger
- Object
- NullLogger
- Bauxite::Loggers::ReportLogger
- Defined in:
- lib/bauxite/core/logger.rb
Overview
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,:skipor:error. -
:capture: path to the current capture, if any.
-
For an example of a ReportLogger implementation see the HtmlLogger class.
Direct Known Subclasses
Instance Method Summary collapse
-
#finalize(ctx) ⇒ Object
Completes the log execution.
-
#initialize(options) ⇒ ReportLogger
constructor
Constructs a new report logger instance.
-
#log(s, type = :info) ⇒ Object
Logs the specified string.
-
#log_cmd(action) ⇒ Object
Echoes the raw action text.
Methods inherited from NullLogger
Constructor Details
#initialize(options) ⇒ ReportLogger
Constructs a new report logger instance.
116 117 118 119 |
# File 'lib/bauxite/core/logger.rb', line 116 def initialize() super() @data = [] end |
Instance Method Details
#finalize(ctx) ⇒ Object
Completes the log execution.
166 167 |
# File 'lib/bauxite/core/logger.rb', line 166 def finalize(ctx) end |
#log(s, type = :info) ⇒ Object
Logs the specified string.
type, if specified, should be one of :error, :warning, :info (default), :debug.
126 127 |
# File 'lib/bauxite/core/logger.rb', line 126 def log(s, type = :info) end |
#log_cmd(action) ⇒ Object
Echoes the raw action text.
130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 |
# 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 |