Sha256: 57145ded4846445435720798bb69e30a9e054e2ce66be0558aa6be2e5e221597

Contents?: true

Size: 810 Bytes

Versions: 8

Compression:

Stored size: 810 Bytes

Contents

require 'httparty'

module SentinelApi
  class Client
    class << self
      def send_to_server(record)
        response = ::HTTParty.public_send(configuration.method, configuration.uri, prepare_request(record))
        unless response.code == 200
          SentinelApi.default_logger.warn("We sent logs(#{record}) to API Server and got #{response.code} instead of status")
        end
      rescue => e
        SentinelApi.default_logger.warn("Troubles with ErrorReporter API call\n #{e.message}\n #{e.backtrace}")
      end

      private

      def prepare_request(record)
        {
            headers: { 'Content-Type' => 'application/json' },
            body: { request_params: record }.to_json
        }
      end

      def configuration
        SentinelApi.configuration
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
logkeeper_api-0.0.9 lib/sentinel_api/client.rb
logkeeper_api-0.0.8 lib/sentinel_api/client.rb
logkeeper_api-0.0.7 lib/sentinel_api/client.rb
logkeeper_api-0.0.6 lib/sentinel_api/client.rb
logkeeper_api-0.0.5 lib/sentinel_api/client.rb
logkeeper_api-0.0.4 lib/sentinel_api/client.rb
logkeeper_api-0.0.3 lib/sentinel_api/client.rb
logkeeper_api-0.0.2 lib/sentinel_api/client.rb