mirror of
https://github.com/django-q2/django-q2.git
synced 2026-10-07 02:58:12 +08:00
Added default logger handler and made coloredlogs optional
This commit is contained in:
+19
-2
@@ -27,7 +27,6 @@ except ImportError:
|
|||||||
import pickle
|
import pickle
|
||||||
|
|
||||||
# External
|
# External
|
||||||
import coloredlogs
|
|
||||||
import redis
|
import redis
|
||||||
import arrow
|
import arrow
|
||||||
|
|
||||||
@@ -43,7 +42,25 @@ from .models import Task, Success, Schedule
|
|||||||
SIGNAL_NAMES = dict((getattr(signal, n), n) for n in dir(signal) if n.startswith('SIG') and '_' not in n)
|
SIGNAL_NAMES = dict((getattr(signal, n), n) for n in dir(signal) if n.startswith('SIG') and '_' not in n)
|
||||||
|
|
||||||
logger = logging.getLogger('django-q')
|
logger = logging.getLogger('django-q')
|
||||||
coloredlogs.install(level=getattr(logging, LOG_LEVEL))
|
|
||||||
|
|
||||||
|
# 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:
|
||||||
|
logger.setLevel(level=getattr(logging, LOG_LEVEL))
|
||||||
|
|
||||||
|
formatter = logging.Formatter(fmt='%(asctime)s [django_q] %(message)s',
|
||||||
|
datefmt='%H:%M:%S')
|
||||||
|
handler = logging.StreamHandler()
|
||||||
|
handler.setFormatter(formatter)
|
||||||
|
logger.addHandler(handler)
|
||||||
|
|
||||||
Q_LIST = '{}:q'.format(PREFIX)
|
Q_LIST = '{}:q'.format(PREFIX)
|
||||||
STARTING = 'Starting'
|
STARTING = 'Starting'
|
||||||
|
|||||||
@@ -81,6 +81,21 @@ USE_L10N = True
|
|||||||
|
|
||||||
USE_TZ = True
|
USE_TZ = True
|
||||||
|
|
||||||
|
LOGGING = {
|
||||||
|
'version': 1,
|
||||||
|
'disable_existing_loggers': False,
|
||||||
|
'handlers': {
|
||||||
|
'console': {
|
||||||
|
'class': 'logging.StreamHandler',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
'loggers': {
|
||||||
|
'django_q': {
|
||||||
|
'handlers': ['console'],
|
||||||
|
'level': 'INFO',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
# Static files (CSS, JavaScript, Images)
|
# Static files (CSS, JavaScript, Images)
|
||||||
# https://docs.djangoproject.com/en/1.8/howto/static-files/
|
# https://docs.djangoproject.com/en/1.8/howto/static-files/
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
arrow==0.5.4
|
arrow==0.5.4
|
||||||
blessed==1.9.5
|
blessed==1.9.5
|
||||||
coloredlogs==1.0.1
|
|
||||||
django-picklefield==0.3.1
|
django-picklefield==0.3.1
|
||||||
Django==1.8.2
|
Django==1.8.2
|
||||||
future==0.14.3
|
future==0.14.3
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ setup(
|
|||||||
license='MIT',
|
license='MIT',
|
||||||
description='A multiprocessing task queue for Django',
|
description='A multiprocessing task queue for Django',
|
||||||
long_description=README,
|
long_description=README,
|
||||||
install_requires=['django>=1.7', 'redis', 'coloredlogs', 'django-picklefield', 'blessed', 'arrow'],
|
install_requires=['django>=1.7', 'redis', 'django-picklefield', 'blessed', 'arrow'],
|
||||||
test_requires=['pytest', 'pytest-django', ],
|
test_requires=['pytest', 'pytest-django', ],
|
||||||
cmdclass={'test': PyTest},
|
cmdclass={'test': PyTest},
|
||||||
classifiers=[
|
classifiers=[
|
||||||
|
|||||||
Reference in New Issue
Block a user