Class: ErrorStalker::Backend::Server
- Defined in:
- lib/error_stalker/backend/server.rb
Overview
Stores reported exceptions to a central ErrorStalker server (a Rack server pointing to an ErrorStalker::Server instance). The most complicated ErrorStalker backend, it is also the most powerful. This is probably what you want to be using in production.
Instance Attribute Summary collapse
-
#host ⇒ Object
The hostname of the ErrorStalker server.
-
#path ⇒ Object
The path of the ErrorStalker server, if applicable.
-
#port ⇒ Object
The ErrorStalker server’s port.
-
#protocol ⇒ Object
http or https.
Instance Method Summary collapse
-
#initialize(params = {}) ⇒ Server
constructor
Creates a new Server backend instance that will report exceptions to a centralized ErrorStalker server.
-
#report(exception_report) ⇒ Object
Reports
exception_report
to a central ErrorStalker server.
Constructor Details
#initialize(params = {}) ⇒ Server
Creates a new Server backend instance that will report exceptions to a centralized ErrorStalker server.
24 25 26 27 28 29 |
# File 'lib/error_stalker/backend/server.rb', line 24 def initialize(params = {}) @protocol = params[:protocol] || 'http://' @host = params[:host] || 'localhost' @port = params[:port] || '5678' @path = params[:path] || '' end |
Instance Attribute Details
#host ⇒ Object
The hostname of the ErrorStalker server
11 12 13 |
# File 'lib/error_stalker/backend/server.rb', line 11 def host @host end |
#path ⇒ Object
The path of the ErrorStalker server, if applicable
20 21 22 |
# File 'lib/error_stalker/backend/server.rb', line 20 def path @path end |
#port ⇒ Object
The ErrorStalker server’s port
14 15 16 |
# File 'lib/error_stalker/backend/server.rb', line 14 def port @port end |
#protocol ⇒ Object
http or https
17 18 19 |
# File 'lib/error_stalker/backend/server.rb', line 17 def protocol @protocol end |
Instance Method Details
#report(exception_report) ⇒ Object
Reports exception_report
to a central ErrorStalker server.
32 33 34 35 36 37 38 39 40 |
# File 'lib/error_stalker/backend/server.rb', line 32 def report(exception_report) req = Net::HTTP::Post.new("#{path}/report.json") req["content-type"] = "application/json" req.body = exception_report.to_json http = Net::HTTP.new(host, port) http.read_timeout = 10 res = http.start { |http| http.request(req) } res end |