From 30f4f2c9dbac5fcc2e30277a4ca11a71b61931bb Mon Sep 17 00:00:00 2001 From: Marin Atanasov Nikolov Date: Wed, 11 Feb 2015 11:41:19 +0200 Subject: [PATCH] Log the traceback if a task fails --- src/vpoller/task/decorators.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/vpoller/task/decorators.py b/src/vpoller/task/decorators.py index 014f6a5..671a61e 100644 --- a/src/vpoller/task/decorators.py +++ b/src/vpoller/task/decorators.py @@ -30,6 +30,7 @@ from functools import wraps from traceback import format_exc +from vpoller.log import logger from vpoller.task.core import Task from vpoller.task.registry import registry @@ -52,11 +53,13 @@ def wrapper(*args, **kwargs): try: result = fn(*args, **kwargs) except Exception as e: + tb = format_exc() result = { 'success': 1, 'msg': 'Task {} failed'.format(name), - 'traceback': format_exc() + 'traceback': tb } + logger.warning('Task %s failed: %s', name, tb) finally: return result t = Task(name=name, function=wrapper, required=required)