LOG MORE, on resque job errors
This commit is contained in:
parent
736783abd7
commit
126a4b2547
2 changed files with 18 additions and 1 deletions
|
|
@ -11,7 +11,11 @@ module ResqueJobLogging
|
|||
end
|
||||
}*1000
|
||||
if error
|
||||
log_string += "status=error error=\"#{error}\" "
|
||||
log_string += "status=error "
|
||||
log_string << "error_class=#{error.class} error_message='#{error.message}' "
|
||||
log_string << "orig_error_message='#{error.original_error.message}'" if error.respond_to?(:original_error)
|
||||
log_string << "annotated_source='#{error.annoted_source_code.to_s}' " if error.respond_to?(:annoted_source_code)
|
||||
log_string << "app_backtrace='#{application_trace(error).join(";")}' "
|
||||
else
|
||||
log_string += "status=complete "
|
||||
end
|
||||
|
|
@ -21,4 +25,10 @@ module ResqueJobLogging
|
|||
Rails.logger.info(log_string)
|
||||
raise error if error
|
||||
end
|
||||
|
||||
def application_trace(error) #copied from ActionDispatch::ShowExceptions
|
||||
defined?(Rails) && Rails.respond_to?(:backtrace_cleaner) ?
|
||||
Rails.backtrace_cleaner.clean(error.backtrace, :silent) :
|
||||
error.backtrace
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -23,4 +23,11 @@ describe ResqueJobLogging do
|
|||
## pass a nil block, so we can test the .info() output
|
||||
ResqueJobLoggingDummy.around_perform_log_job("foo", "bar", "baz") {}
|
||||
end
|
||||
it 'logs stack traces on failure' do
|
||||
Rails.logger.should_receive(:info).with(/app_backtrace=/)
|
||||
proc {
|
||||
ResqueJobLoggingDummy.around_perform_log_job("stuff"){raise "GRAAAAAAAAAGH"}
|
||||
}.should raise_error
|
||||
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Reference in a new issue