Update readme with example
This commit is contained in:
parent
303bf5510b
commit
5ff102f5dd
11
README.md
11
README.md
|
@ -23,7 +23,7 @@ gem 'grape-middleware-logger'
|
||||||
## Usage
|
## Usage
|
||||||
```ruby
|
```ruby
|
||||||
class API < Grape::API
|
class API < Grape::API
|
||||||
# @note Make sure this above you're first +mount+
|
# @note Make sure this is above you're first +mount+
|
||||||
use Grape::Middleware::Logger
|
use Grape::Middleware::Logger
|
||||||
end
|
end
|
||||||
```
|
```
|
||||||
|
@ -54,6 +54,15 @@ The middleware logger can be customized with the following options:
|
||||||
* The `:logger` option can be any object that responds to `.info(String)`
|
* The `:logger` option can be any object that responds to `.info(String)`
|
||||||
* The `:filter` option can be any object that responds to `.filter(Hash)` and returns a hash.
|
* The `:filter` option can be any object that responds to `.filter(Hash)` and returns a hash.
|
||||||
|
|
||||||
|
For example:
|
||||||
|
|
||||||
|
```ruby
|
||||||
|
use Grape::Middleware::Logger, {
|
||||||
|
logger: Logger.new(STDERR),
|
||||||
|
filter: Class.new { def filter(opts) opts.reject { |k, _| k.to_s == 'password' } end }.new
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
## Using Rails?
|
## Using Rails?
|
||||||
`Rails.logger` and `Rails.application.config.filter_parameters` will be used automatically as the default logger and
|
`Rails.logger` and `Rails.application.config.filter_parameters` will be used automatically as the default logger and
|
||||||
param filterer, respectively. This behavior can be overridden by passing the `:logger` or
|
param filterer, respectively. This behavior can be overridden by passing the `:logger` or
|
||||||
|
|
Loading…
Reference in New Issue