lib/napa/middleware/logger.rb in napa-0.4.0 vs lib/napa/middleware/logger.rb in napa-0.4.1

- old
+ new

@@ -1,8 +1,12 @@ +require 'napa/param_sanitizer' + module Napa class Middleware class Logger + include Napa::ParamSanitizer + def initialize(app) @app = app end def call(env) @@ -24,24 +28,25 @@ private def format_request(env) request = Rack::Request.new(env) - params = request.params + params = request.params + begin params = JSON.parse(request.body.read) if env['CONTENT_TYPE'] == 'application/json' rescue # do nothing, params is already set end request_data = { method: request.request_method, path: request.path_info, - query: request.query_string, + query: filtered_query_string(request.query_string), host: Napa::Identity.hostname, pid: Napa::Identity.pid, revision: Napa::Identity.revision, - params: params, + params: filtered_parameters(params), remote_ip: request.ip } request_data[:user_id] = current_user.try(:id) if defined?(current_user) { request: request_data } end