Sha256: 21cbf7065344ae8123385a5bc878322f59da49c69f750033e14c90298e8e8492
Contents?: true
Size: 925 Bytes
Versions: 17
Compression:
Stored size: 925 Bytes
Contents
require 'active_support' module Editmode class Logger attr_accessor :httparty_subscription def log_level=(level) if level == :normal # Add more subscription here enable_httparty! end end 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 def unsubscribe(subscriber) ActiveSupport::Notifications.unsubscribe(subscriber) if subscriber.present? end end end
Version data entries
17 entries across 17 versions & 1 rubygems