Module: Calabash::Android::Logging

Defined in:
lib/calabash-android/logging.rb

Class Method Summary collapse

Class Method Details

.log_debug(msg) ⇒ Object

[email protected] private magenta


18
19
20
21
22
# File 'lib/calabash-android/logging.rb', line 18

def self.log_debug(msg)
  if Calabash::Android::Environment.debug?
    puts self.magenta("DEBUG: #{msg}") if msg
  end
end

.log_error(msg) ⇒ Object

[email protected] private red


32
33
34
# File 'lib/calabash-android/logging.rb', line 32

def self.log_error(msg)
  puts self.red("ERROR: #{msg}") if msg
end

.log_info(msg) ⇒ Object

[email protected] private green


26
27
28
# File 'lib/calabash-android/logging.rb', line 26

def self.log_info(msg)
  puts self.green(" INFO: #{msg}") if msg
end

.log_to_file(message) ⇒ Object


37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/calabash-android/logging.rb', line 37

def self.log_to_file(message)
  timestamp = self.timestamp

  begin
    File.open(self.calabash_log_file, "a:UTF-8") do |file|
      message.split($-0).each do |line|
        file.write("#{timestamp} #{line}#{$-0}")
      end
    end
  rescue => e
    message =
%Q{Could not write:

#{message}

to calabash.log because:

#{e}
}
    self.log_debug(message)
  end
end

.log_warn(msg) ⇒ Object

[email protected] private blue


12
13
14
# File 'lib/calabash-android/logging.rb', line 12

def self.log_warn(msg)
  puts self.blue(" WARN: #{msg}") if msg
end