doc: update how grape logging middleware should be placed (#74)

This commit is contained in:
Luong Vo 2021-07-12 14:02:43 +07:00 committed by GitHub
parent 8afa893a69
commit 6e562a2788
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -19,12 +19,12 @@ Or install it yourself as:
## Basic Usage
In your api file (somewhere on the top)
In your api file (somewhere on the top), insert grape logging middleware before grape error middleware. This is important due to the behaviour of `lib/grape/middleware/error.rb`, which manipulates the status of the response when there is an error.
```ruby
require 'grape_logging'
logger.formatter = GrapeLogging::Formatters::Default.new
use GrapeLogging::Middleware::RequestLogger, { logger: logger }
insert_before Grape::Middleware::Error, GrapeLogging::Middleware::RequestLogger, { logger: logger }
```
**ProTip:** If your logger doesn't support setting formatter you can remove this line - it's optional