Class: Errordite::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/errordite/client.rb

Defined Under Namespace

Classes: Connection

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(server = 'www.errordite.com', port = 443, logger = Errordite.logger) ⇒ Client

Returns a new instance of Client.



6
7
8
9
10
# 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

Instance Attribute Details

#loggerObject (readonly)

Returns the value of attribute logger.



4
5
6
# File 'lib/errordite/client.rb', line 4

def logger
  @logger
end

#portObject (readonly)

Returns the value of attribute port.



4
5
6
# File 'lib/errordite/client.rb', line 4

def port
  @port
end

#serverObject (readonly)

Returns the value of attribute server.



4
5
6
# File 'lib/errordite/client.rb', line 4

def server
  @server
end

Instance Method Details

#post_json(path, body) ⇒ Object



16
17
18
19
20
21
# 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) ⇒ Object



12
13
14
# File 'lib/errordite/client.rb', line 12

def record(error, context)
  post_json '/receiveerror', Errordite::Serializer.new(error, context).to_json
end