Class: PhobosDBCheckpoint::Middleware::Logger
- Inherits:
-
Object
- Object
- PhobosDBCheckpoint::Middleware::Logger
- Defined in:
- lib/phobos_db_checkpoint/middleware/logger.rb
Constant Summary collapse
- RACK_LOGGER =
'rack.logger'.freeze
- SINATRA_ERROR =
'sinatra.error'.freeze
- HTTP_VERSION =
'HTTP_VERSION'.freeze
- PATH_INFO =
'PATH_INFO'.freeze
- REQUEST_METHOD =
'REQUEST_METHOD'.freeze
- QUERY_STRING =
'QUERY_STRING'.freeze
- CONTENT_LENGTH =
'Content-Length'.freeze
Instance Method Summary collapse
- #call(request_env) ⇒ Object
-
#initialize(app, options = {}) ⇒ Logger
constructor
A new instance of Logger.
Constructor Details
#initialize(app, options = {}) ⇒ Logger
Returns a new instance of Logger.
14 15 16 17 18 19 20 |
# File 'lib/phobos_db_checkpoint/middleware/logger.rb', line 14 def initialize(app, = {}) @app = app Phobos.configure(.fetch(:config, 'config/phobos.yml')) Phobos.config.logger.file = .fetch(:log_file, 'log/api.log') Phobos.configure_logger ActiveRecord::Base.logger = Phobos.logger end |
Instance Method Details
#call(request_env) ⇒ Object
22 23 24 25 26 27 28 29 30 31 |
# File 'lib/phobos_db_checkpoint/middleware/logger.rb', line 22 def call(request_env) began_at = Time.now request_env[RACK_LOGGER] = Phobos.logger status, header, body = @app.call(request_env) header = Rack::Utils::HeaderHash.new(header) body = Rack::BodyProxy.new(body) do log(request_env, status, header, began_at) end [status, header, body] end |