Skip to content

Commit

Permalink
Return a Rack::BodyProxy from the Rails::Rack::Logger monkey patch (
Browse files Browse the repository at this point in the history
#333)

* Return a `Rack::BodyProxy` from the `Rails::Rack::Logger` monkey patch

This should return the same object that Rails is returning. See https://github.com/rails/rails/blob/8d1b8e870c1c42859132c8d51ceff0ac72cbe34b/railties/lib/rails/rack/logger.rb#L38

* Update lib/lograge/rails_ext/rack/logger.rb

* Update CHANGELOG.md

* Update logger.rb
  • Loading branch information
ghiculescu authored Jan 24, 2022
1 parent 2fd03f7 commit 7ef493d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
4 changes: 3 additions & 1 deletion lib/lograge/rails_ext/rack/logger.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 7ef493d

Please sign in to comment.