mirror of
https://github.com/samsonjs/grape_logging.git
synced 2026-04-27 14:57:40 +00:00
doc: update how grape logging middleware should be placed (#74)
This commit is contained in:
parent
8afa893a69
commit
6e562a2788
1 changed files with 2 additions and 2 deletions
|
|
@ -19,12 +19,12 @@ Or install it yourself as:
|
||||||
|
|
||||||
## Basic Usage
|
## 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
|
```ruby
|
||||||
require 'grape_logging'
|
require 'grape_logging'
|
||||||
logger.formatter = GrapeLogging::Formatters::Default.new
|
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
|
**ProTip:** If your logger doesn't support setting formatter you can remove this line - it's optional
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue