Module: Facebooker::Logging
- Defined in:
- lib/facebooker/logging.rb
Class Attribute Summary collapse
-
.skip_api_logging ⇒ Object
Returns the value of attribute skip_api_logging.
Class Method Summary collapse
- .format_fb_params(params) ⇒ Object
- .log_fb_api(method, params) ⇒ Object
- .log_info(message, dump, seconds = 0) ⇒ Object
Class Attribute Details
.skip_api_logging ⇒ Object
Returns the value of attribute skip_api_logging.
13 14 15 |
# File 'lib/facebooker/logging.rb', line 13 def skip_api_logging @skip_api_logging end |
Class Method Details
.format_fb_params(params) ⇒ Object
33 34 35 |
# File 'lib/facebooker/logging.rb', line 33 def self.format_fb_params(params) params.map { |key,value| "#{key} = #{value}" }.join(', ') end |
.log_fb_api(method, params) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/facebooker/logging.rb', line 15 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
37 38 39 40 41 |
# File 'lib/facebooker/logging.rb', line 37 def self.log_info(, dump, seconds = 0) return unless Facebooker.logger = "#{} (#{seconds}) #{dump}" Facebooker.logger.info() end |