Big Brother helps you watch and log creates, updates and destroys on your models
Go to file
Guillaume DOTT a83de02b0f Add configure method and logger option to choose other logger 2013-05-29 14:34:52 +02:00
lib Add configure method and logger option to choose other logger 2013-05-29 14:34:52 +02:00
.gitignore First commit 2013-05-27 16:15:47 +02:00
Gemfile First commit 2013-05-27 16:15:47 +02:00
LICENSE.txt Change license to AGPLv3 2013-05-28 10:37:55 +02:00
README.md Add configure method and logger option to choose other logger 2013-05-29 14:34:52 +02:00
Rakefile First commit 2013-05-27 16:15:47 +02:00
rails_big_brother.gemspec Change license to AGPLv3 2013-05-28 10:37:55 +02:00

README.md

RailsBigBrother

RailsBigBrother lets you log every create, update and destroy on any of your models.

Installation

Add this line to your application's Gemfile:

gem 'rails_big_brother'

And then execute:

$ bundle

Or install it yourself as:

$ gem install rails_big_brother

Configuration

RailsBigBrother.config do |config|
  config.format = "big_brother;%<user>s;%<controller_info>s;%<class>s;%<id>s;%<action>s;%<args>s"
  config.logger = Rails.logger
end

Usage

Simply add this line in the model you want to log :

big_brother_watch

User and controller info

To fill user and controller info, you need to define two methods in your ApplicationController

def big_brother_user
  ''
end

def big_brother_infos
  {}
end

big_brother_user must return a string. big_brother_infos can return a string, an array or a hash.

Choose events to log

You can choose which events to log with the on option. For example :

class Example < ActiveRecord::Base
  big_brother_watch on: [:create, :destroy]
end

Select attributes to log

You can specify attributes to monitor with only :

class Example < ActiveRecord::Base
  big_brother_watch only: [:first, :second]
end

You can also ignore some attributes with ignore :

class Example < ActiveRecord::Base
  big_brother_watch ignore: :third
end

Log attributes new value on update

You can choose to log the new value of an updated field with verbose :

class Example < ActiveRecord::Base
  big_brother_watch verbose: :third
end

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request