aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Legler <alex@a3li.li>2010-09-21 19:24:12 +0200
committerAlex Legler <alex@a3li.li>2010-09-23 00:15:00 +0200
commitf9132dfb03fe10ea1194fa7d05f364b6095e4eff (patch)
tree601e6c5e34c372858e442fa2178c29e6bd7bd752 /app/controllers/application_controller.rb
parentFinal fix, works now. (diff)
downloadglsamaker-f9132dfb03fe10ea1194fa7d05f364b6095e4eff.tar.gz
glsamaker-f9132dfb03fe10ea1194fa7d05f364b6095e4eff.tar.bz2
glsamaker-f9132dfb03fe10ea1194fa7d05f364b6095e4eff.zip
Add a helper method to log an error + backtrace + source.
For use especially in AJAX calls that catch errors and error out with HTML 500
Diffstat (limited to 'app/controllers/application_controller.rb')
-rw-r--r--app/controllers/application_controller.rb6
1 files changed, 6 insertions, 0 deletions
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index 68d353b..871a016 100644
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -26,4 +26,10 @@ class ApplicationController < ActionController::Base
logger.warn "[#{Time.now.rfc2822}] UNAUTHORIZED ACCESS by #{current_user.login} from #{request.remote_ip}: #{msg}"
redirect_to :controller => '/index', :action => 'error', :type => 'access'
end
+
+ def log_error(error)
+ caller[0] =~ /`([^']*)'/ and where = $1
+ logger.error "[#{where}] #{error.class}: #{error.to_s}"
+ logger.info error.backtrace.join("\n")
+ end
end