Class: Yeller::Rack
- Inherits:
-
Object
- Object
- Yeller::Rack
- Defined in:
- lib/yeller/rack.rb
Class Method Summary collapse
- .client ⇒ Object
- .configure(&block) ⇒ Object
- .enabled? ⇒ Boolean
- .report(exception, options = {}) ⇒ Object
- .rescue_rack_exception(exception, env) ⇒ Object
- .yeller_http_request_data(request) ⇒ Object
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app) ⇒ Rack
constructor
A new instance of Rack.
Constructor Details
#initialize(app) ⇒ Rack
Returns a new instance of Rack.
26 27 28 |
# File 'lib/yeller/rack.rb', line 26 def initialize(app) @app = app end |
Class Method Details
.client ⇒ Object
22 23 24 |
# File 'lib/yeller/rack.rb', line 22 def self.client @client end |
.configure(&block) ⇒ Object
6 7 8 9 10 |
# File 'lib/yeller/rack.rb', line 6 def self.configure(&block) @config_blocks ||= [] @config_blocks << block @client = Yeller.client(*@config_blocks) end |
.enabled? ⇒ Boolean
17 18 19 20 |
# File 'lib/yeller/rack.rb', line 17 def self.enabled? return false unless @client @client.enabled? end |
.report(exception, options = {}) ⇒ Object
12 13 14 15 |
# File 'lib/yeller/rack.rb', line 12 def self.report(exception, ={}) Yeller::VerifyLog.reporting_to_yeller_rack! @client.report(exception, ) end |
.rescue_rack_exception(exception, env) ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/yeller/rack.rb', line 39 def self.rescue_rack_exception(exception, env) request = ::Rack::Request.new(env) Yeller::Rack.report( exception, :url => request.url, :custom_data => { :params => request.params, :session => env.fetch('rack.session', {}), :"http-request" => Yeller::Rack.yeller_http_request_data(request), }) end |
.yeller_http_request_data(request) ⇒ Object
51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/yeller/rack.rb', line 51 def self.yeller_http_request_data(request) out = { :"request-method" => request.request_method, } if request.user_agent out[:"user-agent"] = request.user_agent end if request.referer out[:referrer] = request.referer end out end |
Instance Method Details
#call(env) ⇒ Object
30 31 32 33 34 35 36 37 |
# File 'lib/yeller/rack.rb', line 30 def call(env) begin @app.call(env) rescue Exception => exception Yeller::Rack.rescue_rack_exception(exception, env) raise exception end end |