增加日志配置

This commit is contained in:
virusdefender 2016-04-28 21:38:55 +08:00
parent ac0453739e
commit 0ad4fa386e
No known key found for this signature in database
GPG Key ID: 1686FB5677979E61
2 changed files with 35 additions and 2 deletions

View File

@ -125,7 +125,6 @@ def _redis_password():
else:
return ""
# celery配置
BROKER_URL = "redis://{password}{host}:{port}/{db}".format(password=_redis_password(),
host=REDIS_LOCAL_QUEUE["host"],
port=REDIS_LOCAL_QUEUE["port"],
@ -139,3 +138,37 @@ CELERY_ROUTES = {
'server.tasks.get_problem': {'queue': 'robot'},
'server.tasks.submit': {'queue': 'robot'},
}
LOGGING = {
'version': 1,
'disable_existing_loggers': True,
'formatters': {
'standard': {
'format': '%(asctime)s [%(threadName)s:%(thread)d] [%(name)s:%(lineno)d] [%(module)s:%(funcName)s] [%(levelname)s]- %(message)s'}
},
'handlers': {
'django_error': {
'level': 'INFO',
'class': 'logging.handlers.RotatingFileHandler',
'filename': 'log/django.log',
'formatter': 'standard'
},
'console': {
'level': 'DEBUG',
'class': 'logging.StreamHandler',
'formatter': 'standard'
}
},
'loggers': {
'django.request': {
'handlers': ['django_error', 'console'],
'level': 'DEBUG',
'propagate': True,
},
'django.db.backends': {
'handlers': ['django_error', 'console'],
'level': 'ERROR',
'propagate': True,
}
},
}

View File

@ -1,6 +1,6 @@
# coding=utf-8
import time
import os
import redis
from celery import Celery
from .utils import Result