pass exc_string as an argument to log (#1934)

* pass exc_string as an argument to log

* fix test of exception log by accessing right arg

* fix black "error"
main
Simon Blanchard 2 years ago committed by GitHub
parent 2faba2cea9
commit c2bec19b09
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1498,7 +1498,9 @@ class Worker(BaseWorker):
extra.update({'queue': job.origin, 'job_id': job.id}) extra.update({'queue': job.origin, 'job_id': job.id})
# func_name # func_name
self.log.error('[Job %s]: exception raised while executing (%s)\n' + exc_string, job.id, func_name, extra=extra) self.log.error(
'[Job %s]: exception raised while executing (%s)\n%s', job.id, func_name, exc_string, extra=extra
)
for handler in self._exc_handlers: for handler in self._exc_handlers:
self.log.debug('Invoking exception handler %s', handler) self.log.debug('Invoking exception handler %s', handler)

@ -268,7 +268,7 @@ class TestWorker(RQTestCase):
w.perform_job(job, queue) w.perform_job(job, queue)
# An exception should be logged here at ERROR level # An exception should be logged here at ERROR level
self.assertIn("Traceback", mock_logger_error.call_args[0][0]) self.assertIn("Traceback", mock_logger_error.call_args[0][3])
def test_heartbeat(self): def test_heartbeat(self):
"""Heartbeat saves last_heartbeat""" """Heartbeat saves last_heartbeat"""

Loading…
Cancel
Save