def setup_logging(debug=False):
"""
Configures logging in cases where a Django environment is not supposed
to be configured.
TODO: This is really confusing, importing django settings is allowed to
fail when debug=False, but if it's true it can fail?
"""
try:
from django.conf.settings import LOGGING
except ImportError:
from kolibri.deployment.default.settings.base import LOGGING
if debug:
from django.conf import settings
settings.DEBUG = True
LOGGING['handlers']['console']['level'] = 'DEBUG'
LOGGING['loggers']['kolibri']['level'] = 'DEBUG'
logger.debug("Debug mode is on!")
logging.config.dictConfig(LOGGING)
评论列表
文章目录