beast rev 2066
[beast-modified.git] / vendor / plugins / exception_logger / README
blobb2398250c5e0710c28551beda5f2910e09afa28b
1 ExceptionLogger
2 ===============
4 The Exception Logger (forgive the horrible name) logs your Rails exceptions in the database and provides a funky web interface to manage them.
6 First you need to generate the migration:
8   ./script/generate exception_migration
10 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:
12   render_404(exception) - Shows the 404 template.
13   
14   render_500(exception) - Shows the 500 template.
15   
16   log_exception(exception) - Logs the actual exception in the database.
17   
18   rescue_action_in_public(exception) - Does not log these exceptions: ActiveRecord::RecordNotFound, ActionController::UnknownController, ActionController::UnknownAction
20 After that, visit /logged_exceptions in your application to manage the exceptions.
22 It's understandable that you may want to require authentication.  Add this to your config/environments/production.rb:
24   # config/environments/production.rb
25   config.after_initialize do
26     require 'application' unless Object.const_defined?(:ApplicationController)
27     LoggedExceptionsController.class_eval do
28       # set the same session key as the app
29       session :session_key => '_beast_session_id'
30       
31       # include any custom auth modules you need
32       include AuthenticationSystem
33       
34       before_filter :login_required
35       
36       # optional, sets the application name for the rss feeds
37       self.application_name = "Beast"
38       
39       protected
40         # only allow admins
41         # this obviously depends on how your auth system works
42         def authorized?
43           current_user.is_a?(Admin)
44         end
45         
46         # assume app's login required doesn't use http basic
47         def login_required_with_basic
48           respond_to do |accepts|
49             # alias_method_chain will alias the app's login_required to login_required_without_basic
50             accepts.html { login_required_without_basic }
51             
52             # access_denied_with_basic_auth is defined in LoggedExceptionsController
53             # get_auth_data returns back the user/password pair
54             accepts.rss do
55               access_denied_with_basic_auth unless self.current_user = User.authenticate(*get_auth_data)
56             end
57           end
58         end
59         
60         alias_method_chain :login_required, :basic
61     end
62   end
64 The exact code of course depends on the specific needs of your application.
66 CREDITS
68 Jamis Buck  - original exception_notification plugin
69 Rick Olson  - model/controller code
70 Josh Goebel - design