class Editmode::Logger
Attributes
httparty_subscription[RW]
Public Instance Methods
enable_httparty!()
click to toggle source
# File lib/editmode/logger.rb, line 14 def enable_httparty! @httparty_subscription = ActiveSupport::Notifications.subscribe('request.httparty') do |name, start, ending, transaction_id, payload| event = ActiveSupport::Notifications::Event.new(name, start, ending, transaction_id, payload) Rails.logger.info " HTTParty -- " + "#{event.payload[:method]} #{event.payload[:url]} (Duration: #{event.duration}ms)" Thread.current[:http_runtime] ||= 0 Thread.current[:http_runtime] += event.duration payload[:http_runtime] = event.duration end end
log_level=(level)
click to toggle source
# File lib/editmode/logger.rb, line 7 def log_level=(level) if level == :normal # Add more subscription here enable_httparty! end end
unsubscribe(subscriber)
click to toggle source
# File lib/editmode/logger.rb, line 24 def unsubscribe(subscriber) ActiveSupport::Notifications.unsubscribe(subscriber) if subscriber.present? end