Update readme with example

This commit is contained in:
Ryan Buckley 2016-05-12 19:57:11 +08:00
parent 303bf5510b
commit 5ff102f5dd
1 changed files with 10 additions and 1 deletions

View File

@ -23,7 +23,7 @@ gem 'grape-middleware-logger'
## Usage
```ruby
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
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 `: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?
`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