Module: Calculated::Logging

Defined in:
lib/calculated/logging.rb

Class Method Summary (collapse)

Class Method Details

+ (Object) format_da_dump(path, params)



30
31
32
# File 'lib/calculated/logging.rb', line 30

def self.format_da_dump(path, params)
  "Calculated: PATH: #{path} PARAMS: #{params.inspect}"
end

+ (Object) log_calculated_api(method, path, options)



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

def self.log_calculated_api(method, path, options)
  message = method 
  dump = format_da_dump(path, options)
  if block_given?
    result = nil
    seconds = Benchmark.realtime { result = yield }
    log_info(message, dump, seconds) 
    result
  else
    log_info(message, dump) 
    nil
  end
rescue Exception => e
  exception = "#{e.class.name}: #{e.message}: #{dump}"
  log_info(message, exception)
  raise
end

+ (Object) log_info(message, dump, seconds = 0)



34
35
36
37
38
# File 'lib/calculated/logging.rb', line 34

def self.log_info(message, dump, seconds = 0)
  return unless Calculated.logger
  log_message = "#{message} (#{seconds}) #{dump}"
  Calculated.logger.info(log_message)
end