class Errordite::Client
Attributes
logger[R]
port[R]
server[R]
Public Class Methods
new(server = 'www.errordite.com', port = 443, logger = Errordite.logger)
click to toggle source
# File lib/errordite/client.rb, line 6 def initialize(server = 'www.errordite.com', port = 443, logger = Errordite.logger) @server = server @port = port @logger = logger end
Public Instance Methods
post_json(path, body)
click to toggle source
# File lib/errordite/client.rb, line 16 def post_json(path, body) headers = {'Content-Type' => 'application/json; charset=utf-8', 'Content-Length' => body.size.to_s} response = Connection.new(server, port).post path, body, headers log_response response response end
record(error, context)
click to toggle source
# File lib/errordite/client.rb, line 12 def record(error, context) post_json '/receiveerror', Errordite::Serializer.new(error, context).to_json end
Private Instance Methods
log_response(response)
click to toggle source
# File lib/errordite/client.rb, line 25 def log_response(response) if response.code != "201" logger.warn "Failed to log error: #{response.code} #{response.message}" elsif logger.debug? logger.debug "Error logged: #{response.code} #{response.message}" end end