Class: Howitzer::Log

Inherits:
Object
  • Object
show all
Includes:
Log4r, Singleton
Defined in:
lib/howitzer/utils/log.rb

Instance Method Summary collapse

Instance Method Details

#error(*args) ⇒ Object

Prints log entry about error with ERROR severity Examples:

log.error MyException, 'Some error text', caller
log.error 'Some error text', caller
log.error MyException, 'Some caller text'
log.error 'Some error text'
log.error err_object

Parameters:

  • args - see example


29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/howitzer/utils/log.rb', line 29

def error(*args)
  object = if args.first.nil?
    $!
  else
    case args.size
      when 1
       args.first.is_a?(Exception) ? args.first : RuntimeError.new(args.first)
      when 2
        if args.first.is_a?(Class) && args.first < Exception
          args.first.new(args.last)
        else
          exception = RuntimeError.new(args.first)
          exception.set_backtrace(args.last)
          exception
        end
      when 3
       exception = args.first.new(args[1])
       exception.set_backtrace(args.last)
       exception
      #:nocov:
      else nil
      #:nocov:
    end
  end
  err_backtrace = object.backtrace ? "\n\t#{object.backtrace.join("\n\t")}" : nil
  @logger.error("[#{object.class}] #{object.message}#{err_backtrace}")
  fail(object)
end

Prints feature name into log with INFO severity

Parameters:

  • text - Feature name


66
67
68
# File 'lib/howitzer/utils/log.rb', line 66

def print_feature_name(text)
  log_without_formatting{ info "*** Feature: #{text.upcase} ***" }
end

Prints scenario name into log with INFO severity

Parameters:

  • text - Scenario name


86
87
88
# File 'lib/howitzer/utils/log.rb', line 86

def print_scenario_name(text)
  log_without_formatting{ info " => Scenario: #{text}" }
end

#settings_as_formatted_textObject

Returns formatted howitzer settings


75
76
77
# File 'lib/howitzer/utils/log.rb', line 75

def settings_as_formatted_text
  log_without_formatting{ info settings.as_formatted_text }
end