public
Fork of anotherjesse/exception_logger
Description: our hacks to exception_logger
Clone URL: git://github.com/indirect/exception_logger.git
Search Repo:
name age message
folder README Mon Feb 11 21:04:21 -0800 2008 a few hacks we use at dancejam [anotherjesse]
folder Rakefile Fri Jun 23 21:43:30 -0700 2006 first public version of logged exceptions plugin [technoweenie]
folder assets/ Sun Sep 03 20:57:56 -0700 2006 add RSS feed support [technoweenie]
folder generators/ Wed Feb 21 08:14:40 -0800 2007 update logged_exception message column to TEXT ... [technoweenie]
folder init.rb Sun Jan 13 12:00:59 -0800 2008 modify the plugin to use (and require) will_pag... [defunkt]
folder install.rb Sun Jul 02 06:55:40 -0700 2006 enhance readme docs [technoweenie]
folder lib/ Mon Feb 11 21:33:02 -0800 2008 ensure proper mime/type via format.js on show/d... [anotherjesse]
folder tasks/ Fri Jun 23 21:43:30 -0700 2006 first public version of logged exceptions plugin [technoweenie]
folder test/ Fri Jun 23 21:43:30 -0700 2006 first public version of logged exceptions plugin [technoweenie]
folder uninstall.rb Fri Jun 23 21:43:30 -0700 2006 first public version of logged exceptions plugin [technoweenie]
folder views/ Sun Jan 13 12:00:59 -0800 2008 modify the plugin to use (and require) will_pag... [defunkt]
README
ExceptionLogger
===============

The Exception Logger (forgive the horrible name) logs your Rails exceptions in the database and provides a funky web 
interface to manage them.

First you need to generate the migration:

  ./script/generate exception_migration

Next, you'll need to include the ExceptionLoggable module into ApplicationController.  Once that's done you might want 
to modify key methods to customize the logging:

  render_404(exception) - Shows the 404 template.
  
  render_500(exception) - Shows the 500 template.
  
  log_exception(exception) - Logs the actual exception in the database.
  
  rescue_action_in_public(exception) - Does not log these exceptions: ActiveRecord::RecordNotFound, 
  ActionController::UnknownController, ActionController::UnknownAction

After that, visit /logged_exceptions in your application to manage the exceptions.

It's understandable that you may want to require authentication.  Add this to your config/environments/production.rb:

  # config/environments/production.rb
  config.after_initialize do
    require 'application' unless Object.const_defined?(:ApplicationController)
    LoggedExceptionsController.class_eval do
      # set the same session key as the app
      session :session_key => '_beast_session_id'
      
      # include any custom auth modules you need
      include AuthenticationSystem
      
      before_filter :login_required
      
      # optional, sets the application name for the rss feeds
      self.application_name = "Beast"
      
      protected
        # only allow admins
        # this obviously depends on how your auth system works
        def authorized?
          current_user.is_a?(Admin)
        end
        
        # assume app's login required doesn't use http basic
        def login_required_with_basic
          respond_to do |accepts|
            # alias_method_chain will alias the app's login_required to login_required_without_basic
            accepts.html { login_required_without_basic }
            
            # access_denied_with_basic_auth is defined in LoggedExceptionsController
            # get_auth_data returns back the user/password pair
            accepts.rss do
              access_denied_with_basic_auth unless self.current_user = User.authenticate(*get_auth_data)
            end
          end
        end
        
        alias_method_chain :login_required, :basic
    end
  end

The exact code of course depends on the specific needs of your application.

CREDITS

Jamis Buck  - original exception_notification plugin
Rick Olson  - model/controller code
Josh Goebel - design

UPDATES

Chris Wanstrath - use will_paginate
Henrik Nyh (DanceJam) - catch exceptions in development mode