Class: Errordite::Client
- Inherits:
-
Object
- Object
- Errordite::Client
- Defined in:
- lib/errordite/client.rb
Defined Under Namespace
Classes: Connection
Instance Attribute Summary collapse
-
#logger ⇒ Object
readonly
Returns the value of attribute logger.
-
#port ⇒ Object
readonly
Returns the value of attribute port.
-
#server ⇒ Object
readonly
Returns the value of attribute server.
Instance Method Summary collapse
-
#initialize(server = 'www.errordite.com', port = 443, logger = Errordite.logger) ⇒ Client
constructor
A new instance of Client.
- #post_json(path, body) ⇒ Object
- #record(error, context) ⇒ Object
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
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
4 5 6 |
# File 'lib/errordite/client.rb', line 4 def logger @logger end |
#port ⇒ Object (readonly)
Returns the value of attribute port.
4 5 6 |
# File 'lib/errordite/client.rb', line 4 def port @port end |
#server ⇒ Object (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 |