Module: Amazon::Util::Logging

Constant Summary collapse

@@AmazonLogger =
nil

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.deprecated(name, alt: nil, from: nil) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/amazon/util/logging.rb', line 12

def self.deprecated( name, alt: nil, from: nil )
  warning = "DEPRECATION WARNING: #{name} is deprecated."
  if alt
    warning += " (use #{alt} instead)"
  end
  if from
    warning += " Called by #{Kernel.caller.first}"
  end
  if @@AmazonLogger
    @@AmazonLogger.warn warning
  else
    puts warning
  end
end

Instance Method Details

#log(str) ⇒ Object



31
32
33
34
# File 'lib/amazon/util/logging.rb', line 31

def log( str )
  set_log 'mturk.log' if @@AmazonLogger.nil?
  @@AmazonLogger.debug str
end

#set_log(filename) ⇒ Object



27
28
29
# File 'lib/amazon/util/logging.rb', line 27

def set_log( filename )
  @@AmazonLogger = Logger.new filename
end