Module: Calabash::Cucumber::Logging

Overview

internal logging methods for calabash-ios gem

Constant Summary collapse

CALABASH_NO_DEPRECATION =

controls printing of deprecation warnings

to inhibit deprecation message set this to ‘1’

inhibiting deprecation messages is not recommend

ENV['CALABASH_NO_DEPRECATION'] || '0'

Instance Method Summary collapse

Instance Method Details

#_deprecated(version, msg, type) ⇒ Object

prints a deprecated message that includes the line number

if ENV == ‘1’ then this method is a nop

Parameters:

  • version (String)

    indicates when the feature was deprecated

  • msg (String)

    deprecation message (possibly suggesting alternatives)

  • type (Symbol)

    { :warn | :pending } - :pending will raise a cucumber pending exception



67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# File 'lib/calabash-cucumber/utils/logging.rb', line 67

def _deprecated(version, msg, type)
  allowed = [:pending, :warn]
  unless allowed.include?(type)
    raise "type '#{type}' must be on of '#{allowed}'"
  end

  unless no_deprecation_warnings?

    if RUBY_VERSION < '2.0'
      stack = Kernel.caller()[1..6].join("\n")
    else
      stack = Kernel.caller(0, 6)[1..-1].join("\n")
    end

    msg = "deprecated '#{version}' - '#{msg}'\n#{stack}"

    if type.eql?(:pending)
      pending(msg)
    else
      begin
        warn "\033[34m\nWARN: #{msg}\033[0m"
      rescue
        warn "\nWARN: #{msg}"
      end
    end
  end
end

#calabash_info(msg) ⇒ Object

prints a green info message

Parameters:

  • msg (String)

    the message to print



38
39
40
41
42
43
44
# File 'lib/calabash-cucumber/utils/logging.rb', line 38

def calabash_info(msg)
  begin
    puts "\033[32m\nINFO: #{msg}\033[0m"
  rescue
    puts "\nINFO: #{msg}"
  end
end

#calabash_warn(msg) ⇒ Object

prints a blue/cyan warning message

Parameters:

  • msg (String)

    the message to print



28
29
30
31
32
33
34
# File 'lib/calabash-cucumber/utils/logging.rb', line 28

def calabash_warn(msg)
  begin
    warn "\033[34m\nWARN: #{msg}\033[0m"
  rescue
    warn "\nWARN: #{msg}"
  end
end

#debug_logging?Boolean

controls whether or not calabash logs debug information

Returns:

  • (Boolean)

    true if the DEBUG is set to ‘1’



22
23
24
# File 'lib/calabash-cucumber/utils/logging.rb', line 22

def debug_logging?
  ENV['DEBUG'] == '1'
end

#full_console_logging?Boolean

controls the the kind of information calabash logs

this is considered one level above debug logging - maybe we should call the info log level.

Returns:

  • (Boolean)

    true if the CALABASH_FULL_CONSOLE_OUTPUT is set to ‘1’



15
16
17
# File 'lib/calabash-cucumber/utils/logging.rb', line 15

def full_console_logging?
  ENV['CALABASH_FULL_CONSOLE_OUTPUT'] == '1'
end

#no_deprecation_warnings?Boolean

returns true if the CALABASH_NO_DEPRECATION variable is set to 1

Returns:

  • (Boolean)


55
56
57
# File 'lib/calabash-cucumber/utils/logging.rb', line 55

def no_deprecation_warnings?
  ENV['CALABASH_NO_DEPRECATION'] == '1'
end