Module: Facebooker::Logging
- Defined in:
- lib/facebooker/logging.rb
Class Method Summary collapse
- .format_fb_params(params) ⇒ Object
- .log_fb_api(method, params) ⇒ Object
- .log_info(message, dump, seconds = 0) ⇒ Object
- .skip_api_logging ⇒ Object
- .skip_api_logging=(val) ⇒ Object
Class Method Details
.format_fb_params(params) ⇒ Object
40 41 42 |
# File 'lib/facebooker/logging.rb', line 40 def self.format_fb_params(params) params.map { |key,value| "#{key} = #{value}" }.join(', ') end |
.log_fb_api(method, params) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/facebooker/logging.rb', line 22 def self.log_fb_api(method, params) = method # might customize later dump = format_fb_params(params) if block_given? result = nil seconds = Benchmark.realtime { result = yield } log_info(, dump, seconds) unless skip_api_logging result else log_info(, dump) unless skip_api_logging nil end rescue Exception => e exception = "#{e.class.name}: #{e.}: #{dump}" log_info(, exception) raise end |
.log_info(message, dump, seconds = 0) ⇒ Object
44 45 46 47 48 |
# File 'lib/facebooker/logging.rb', line 44 def self.log_info(, dump, seconds = 0) return unless Facebooker.logger = "#{} (#{seconds}) #{dump}" Facebooker.logger.debug() end |
.skip_api_logging ⇒ Object
17 18 19 |
# File 'lib/facebooker/logging.rb', line 17 def self.skip_api_logging @skip_api_logging end |
.skip_api_logging=(val) ⇒ Object
13 14 15 |
# File 'lib/facebooker/logging.rb', line 13 def self.skip_api_logging=(val) @skip_api_logging=val end |