Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

allow extra data to be logged. log data for all statuses except 404

git-svn-id: http://svn.techno-weenie.net/projects/plugins/exception_logger@2706 567b1171-46fb-0310-a4c9-b4bef9110e78
  • Loading branch information...
commit 403c915a5e0ddecb69eca658afa02de3f866efc1 1 parent 9e2706f
technoweenie authored
View
7 lib/exception_loggable.rb
@@ -39,7 +39,8 @@ def local_addresses
addresses
end
- def exception_data(deliverer=self)
+ def exception_data(deliverer = self, &block)
+ deliverer = block if block
if deliverer == self
read_inheritable_attribute(:exception_data)
else
@@ -56,7 +57,7 @@ def local_request?
def rescue_action_in_public(exception)
status = response_code_for_rescue(exception)
render_optional_error_file status
- log_exception(exception) if status == :internal_server_error
+ log_exception(exception) if status != :not_found
end
def log_exception(exception)
@@ -67,6 +68,6 @@ def log_exception(exception)
when Proc then deliverer.call(self)
end
- LoggedException.create_from_exception(self, exception)
+ LoggedException.create_from_exception(self, exception, data)
end
end
View
6 lib/logged_exception.rb
@@ -1,11 +1,13 @@
class LoggedException < ActiveRecord::Base
class << self
- def create_from_exception(controller, exception)
+ def create_from_exception(controller, exception, data)
+ message = exception.message.inspect
+ message << "\n* Extra Data\n\n#{data}" unless data.blank?
create! \
:exception_class => exception.class.name,
:controller_name => controller.controller_name,
:action_name => controller.action_name,
- :message => exception.message.inspect,
+ :message => message,
:backtrace => exception.backtrace,
:request => controller.request
end
View
2  views/logged_exceptions/_show.rhtml
@@ -18,7 +18,7 @@
<h2>Backtrace</h2>
-<%= content_tag 'p', @exc.message, :class => 'intro' %>
+<%= simple_format @exc.message %>
<div id="backtrace">
<%=h(@exc.backtrace).gsub(/\n/,"<br />") %>
Please sign in to comment.
Something went wrong with that request. Please try again.