Module: Calculated::Logging
- Defined in:
- lib/calculated/logging.rb
Class Method Summary collapse
- .format_da_dump(path, params) ⇒ Object
- .log_calculated_api(method, path, options) ⇒ Object
- .log_info(message, dump, seconds = 0) ⇒ Object
Class Method Details
.format_da_dump(path, params) ⇒ Object
30 31 32 |
# File 'lib/calculated/logging.rb', line 30 def self.format_da_dump(path, params) "Calculated: PATH: #{path} PARAMS: #{params.inspect}" end |
.log_calculated_api(method, path, options) ⇒ Object
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, ) = method dump = format_da_dump(path, ) if block_given? result = nil seconds = Benchmark.realtime { result = yield } log_info(, dump, seconds) result else log_info(, dump) nil end rescue Exception => e exception = "#{e.class.name}: #{e.}: #{dump}" log_info(, exception) raise end |
.log_info(message, dump, seconds = 0) ⇒ Object
34 35 36 37 38 |
# File 'lib/calculated/logging.rb', line 34 def self.log_info(, dump, seconds = 0) return unless Calculated.logger = "#{} (#{seconds}) #{dump}" Calculated.logger.info() end |