mirror of
https://github.com/django-q2/django-q2.git
synced 2026-10-06 06:08:12 +08:00
Removed coloredlogs
This commit is contained in:
+14
-21
@@ -41,19 +41,10 @@ from .models import Task, Success, Schedule
|
|||||||
|
|
||||||
logger = logging.getLogger('django-q')
|
logger = logging.getLogger('django-q')
|
||||||
|
|
||||||
|
# Set up standard logging handler in case there is none
|
||||||
# Optional coloredlogs support
|
|
||||||
try:
|
|
||||||
import coloredlogs
|
|
||||||
|
|
||||||
coloredlogs.install(level=getattr(logging, LOG_LEVEL))
|
|
||||||
except ImportError:
|
|
||||||
coloredlogs = None
|
|
||||||
|
|
||||||
# Set up standard logging handler
|
|
||||||
if not logger.handlers:
|
if not logger.handlers:
|
||||||
logger.setLevel(level=getattr(logging, LOG_LEVEL))
|
logger.setLevel(level=getattr(logging, LOG_LEVEL))
|
||||||
formatter = logging.Formatter(fmt='%(asctime)s [django_q] %(message)s',
|
formatter = logging.Formatter(fmt='%(asctime)s [Q] %(levelname)s %(message)s',
|
||||||
datefmt='%H:%M:%S')
|
datefmt='%H:%M:%S')
|
||||||
handler = logging.StreamHandler()
|
handler = logging.StreamHandler()
|
||||||
handler.setFormatter(formatter)
|
handler.setFormatter(formatter)
|
||||||
@@ -326,7 +317,6 @@ def worker(task_queue, done_queue):
|
|||||||
m = importlib.import_module(module)
|
m = importlib.import_module(module)
|
||||||
f = getattr(m, func)
|
f = getattr(m, func)
|
||||||
except (ValueError, ImportError, AttributeError) as e:
|
except (ValueError, ImportError, AttributeError) as e:
|
||||||
logger.error(e)
|
|
||||||
return_pack(e, False)
|
return_pack(e, False)
|
||||||
continue
|
continue
|
||||||
# execute the payload
|
# execute the payload
|
||||||
@@ -344,15 +334,18 @@ def save_task(task):
|
|||||||
"""
|
"""
|
||||||
if task['success'] and 0 < SAVE_LIMIT < Success.objects.count():
|
if task['success'] and 0 < SAVE_LIMIT < Success.objects.count():
|
||||||
Success.objects.first().delete()
|
Success.objects.first().delete()
|
||||||
Task.objects.create(name=task['name'],
|
try:
|
||||||
func=task['func'],
|
Task.objects.create(name=task['name'],
|
||||||
hook=task['hook'],
|
func=task['func'],
|
||||||
args=task['args'],
|
hook=task['hook'],
|
||||||
kwargs=task['kwargs'],
|
args=task['args'],
|
||||||
started=task['started'],
|
kwargs=task['kwargs'],
|
||||||
stopped=task['stopped'],
|
started=task['started'],
|
||||||
result=task['result'],
|
stopped=task['stopped'],
|
||||||
success=task['success'])
|
result=task['result'],
|
||||||
|
success=task['success'])
|
||||||
|
except Exception as e:
|
||||||
|
logger.exception(e)
|
||||||
|
|
||||||
|
|
||||||
def async(func, *args, **kwargs):
|
def async(func, *args, **kwargs):
|
||||||
|
|||||||
Reference in New Issue
Block a user