If you wanna use this gem, you'll need to be running Grape master #dd0cae27 (April 30) or later. Otherwise, you'll have to wait for the release of 0.12.0
This version is for providing these logs to logstash.
Add this line to your application's Gemfile:
gem 'grape', github: 'intridea/grape', branch: 'master', ref: 'dd0cae274ee0017a22deef5e282b75cf25d65385'
gem 'grape-middleware-logger'
class API < Grape::API
use Grape::Middleware::Logger
end
Using Grape with Rails or want to customize the logging? You can provide a logger
option, which just has to respond to .info(msg)
. Example Rails logging and parameter sanitization:
use Grape::Middleware::Logger, {
logger: Rails.logger,
filter: ActionDispatch::Http::ParameterFilter.new(Rails.application.config.filter_parameters)
}
The filter
option can be any object that responds to .filter(params_hash)
Big thanks to jadent's question/answer on stackoverflow for easily logging error responses. Borrowed some motivation from the grape_logging gem and would love to see these two consolidated at some point.
- Fork it ( https://github.com/ridiculous/grape-middleware-logger/fork )
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request