diff --git a/CHANGELOG.md b/CHANGELOG.md index 5effc384..a67addeb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Change Log +### Unreleased + +* Return a `Rack::BodyProxy` from the `Rails::Rack::Logger` monkey patch, this ensures the same return type as Rails [#333](https://github.com/roidrage/lograge/pull/333) + ### 0.11.2 * Resolve a bug with Action Cable registration [#286](https://github.com/roidrage/lograge/pull/286) diff --git a/lib/lograge/rails_ext/rack/logger.rb b/lib/lograge/rails_ext/rack/logger.rb index 38c937da..8d045315 100644 --- a/lib/lograge/rails_ext/rack/logger.rb +++ b/lib/lograge/rails_ext/rack/logger.rb @@ -15,7 +15,9 @@ class Logger # Overwrites Rails code that logs new requests def call_app(*args) env = args.last - @app.call(env) + status, headers, body = @app.call(env) + # needs to have same return type as the Rails builtins being overridden, see https://github.com/roidrage/lograge/pull/333 + [status, headers, ::Rack::BodyProxy.new(body)] ensure ActiveSupport::LogSubscriber.flush_all! end