This gem provide simple wrapper for gelf-rb gem and extending middleware stack of rails application for exception logging to Graylog2.
Add this line to your application's Gemfile:
gem "graylog2-rails", "~> 0.0.1"
And then execute:
$ bundle
Or install it yourself as:
$ gem install graylog2-rails
It is highly recommended to customize Graylog2Rails config
$ rails g graylog2_rails:install
It will copy default config file into config/graylog2_rails.conf
file.
If you want only to catch exception and you need do nothing. To check middleware stack run bundle exec rake middleware
and you will see something like:
use ActionDispatch::Flash
use ActionDispatch::ParamsParser
use ActionDispatch::Head
use Graylog2Rails::Middleware <----
use Rack::ConditionalGet
use Rack::ETag
use ActionDispatch::BestStandardsSupport
use Warden::Manager
use Bullet::Rack
use Sass::Plugin::Rack
You also may use Graylog2Rails for logging custom messages:
Graylog2Rails::Notifier.notify!({
:short_message => "Your short message here",
:full_message => "Full message"
})
You also may redefine default options like facility
or pass custom filter arguments like in gelf-rb
. For example:
Graylog2Rails::Notifier.notify!({
:short_message => "Your short message here",
:full_message => "Full message",
:_user_id => current_user.id
})
You should notice that such custom options have to be started with underline
- Add rspec tests
- Cutomize message format and move it's representation to erb file
- Fork it
- 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 new Pull Request
copyright 2012 Artem (ignar) Melnikov