public
Description: Substitution of the standard Rails logger with implementation that writes data in the DB as regular AR objects.
Homepage:
Clone URL: git://github.com/shine/dblogger.git
README
=== General idea ===
This is hack of Ruby on Rails framework. Sometimes it can be very usefull to take
immediate feedback from user inside application. This hack lets you to do this.

=== Practice ===
For example, if we have deployed wrong code and some action of popular controller
throws exceptions it can be very useful to catch 100% of errors for this request 
during last few minutes and redirect user to other - more stable - page. It will
be much more user friendly than big-red-error message about 500 server error.

Another feature you can do with this hack is complete user actions monitoring. In
the first Rails Recipes there was similar recipe that was extremely non-DRY. Now
we can store all information in one place and in one instance.

=== Status ===
Beta.

I'll recomend to use very carefully in production projects. It work well with 
unstandard types of event so feel free to create you own types and use.

=== How it should be installed ===
You are replacing few methods of regular Rails logger with new version in the 
models/dblogger.rb
You are creating additional tables in db using migrations.
You are rebooting your web server and "Whoops" :)

=== What should I get with this addon? ===
Requests received during last 3 days:
LoggedRequest.during_last 3.days #=> Array of LoggedRequest objects

Requests of index action in all controllers during last 10 minutes:
LoggedRequest.during_last 10.minutes, {:action => 'index'}

Requests with status ERROR and FATAL during last 10 minutes:
LoggedRequest.errors_during_last 10.minutes

Percent of the WARN, ERROR and FATAL messages in the whole message number during last 2 days:
LoggedRequest.percent_of_warn_during_last 2.days #=> 0.239 (23.9%)

Remove all logs for current environment:
rake db:log:clear

Find latest error happened
LoggedRequest.latest_error

... or just read and learn Shoulda specs

=== How fast is it? ===
I have not made complete investigation of this detail and I have not made any
optimisation of performance. Meanwhile, I have added it to one of my current
projects and runned 'rake spec'.

Standard logger: 28.10 seconds
DBLogger: 40.02 seconds

So we have +42% of time needed to run rspec right now.

Is it big? I think it is not. It is fair price for huge flexibility boost of your 
application configuration.

=== License ===
WTFPL

=== I ===
Victor Brylew <victor.brylew@gmail.com>
Ruby on Rails freelance programmer