Class: Logworm::Rack
- Inherits:
-
Object
- Object
- Logworm::Rack
- Defined in:
- lib/logworm_client/rack.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, options = {}) ⇒ Rack
constructor
A new instance of Rack.
Constructor Details
#initialize(app, options = {}) ⇒ Rack
Returns a new instance of Rack.
6 7 8 9 10 11 12 13 14 |
# File 'lib/logworm_client/rack.rb', line 6 def initialize(app, = {}) @app = app @log_requests = ([:donot_log_requests].nil? or [:donot_log_requests] != true) @log_headers = ([:log_headers] and [:log_headers] == true) @dev_logging = ([:log_in_development] and [:log_in_development] == true) Logger.use_default_db @timeout = 1 end |
Instance Method Details
#call(env) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/logworm_client/rack.rb', line 16 def call(env) return @app.call(env) unless (ENV['RACK_ENV'] == 'production' or (ENV['RACK_ENV'] == 'development' and @dev_logging)) Logger.start_cycle begin startTime = Time.now status, response_headers, body = @app.call(env) appTime = (Time.now - startTime) ensure log_request(env, status, response_headers, appTime) return [status, response_headers, body] end end |