Created
January 22, 2015 14:06
-
-
Save jordanyaker/ae241b3d25f1dfac718e to your computer and use it in GitHub Desktop.
Adding Exception Logging In Rails For All Exceptions
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Exception | |
alias real_init initialize | |
def initialize(*args) | |
real_init *args | |
unless message == 'Resource temporarily unavailable - read would block' || | |
caller.any? { |c| c =~ /.*\/var\/www\/web\/shared\/vendor\/bundle\/ruby\/2\.0\.0\/bin\/rake:23:in/i } | |
breaker = "------------------------------------------------------" | |
Rails.logger.info breaker | |
Rails.logger.info breaker | |
Rails.logger.info self.class.name | |
Rails.logger.info("MESSAGE: #{message}") unless message.nil? | |
if backtrace.nil? | |
Rails.logger.info "CALLER:\n" + caller.join("\n") | |
else | |
Rails.logger.info "BACKTRACE:\n" + backtrace.join("\n") | |
end | |
Rails.logger.info breaker | |
Rails.logger.info breaker | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
where to put this file?