Sha256: 0442bb7c45e38d284638ed0eee2237b436c7fe0f91da372fd7ca6ab137dad989

Contents?: true

Size: 615 Bytes

Versions: 4

Compression:

Stored size: 615 Bytes

Contents

module RestClient
  module Jogger
    class RequestComplete
      include ::ActiveModel::Model
      attr_accessor :logger, :notifier

      def initialize(args = {})
        self.logger = args.fetch :logger
        super
      end

      def notifier
        @notifier ||= ::Rollbar
      end

      def call(name, start, finish, id, payload)
        message = ::JSON.dump(payload.merge(event_name: name, event_id: id, timestamp: start))
        name =~ /error/ ? logger.error(message) : logger.debug(message)
      rescue StandardError => e
        notifier.error e, payload: payload
      end

    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rest-client-jogger-0.3.5 lib/rest_client/jogger/request_complete.rb
rest-client-jogger-0.3.4 lib/rest_client/jogger/request_complete.rb
rest-client-jogger-0.3.3 lib/rest_client/jogger/request_complete.rb
rest-client-jogger-0.3.2 lib/rest_client/jogger/request_complete.rb