Fixed issues with log not working.

This commit is contained in:
Tiberiu Chibici 2018-12-30 00:10:30 +02:00
parent 8988a39c47
commit 0fce462818
2 changed files with 7 additions and 7 deletions

View File

@ -118,6 +118,7 @@ MEDIA_URL = '/media/'
CRISPY_TEMPLATE_PACK = 'bootstrap4'
LOG_FORMAT = '%(asctime)s|%(process)d|%(thread)d|%(name)s|%(filename)s|%(lineno)d|%(levelname)s|%(message)s'
CONSOLE_LOG_FORMAT = '%(asctime)s | %(name)s | %(filename)s:%(lineno)d | %(levelname)s | %(message)s'
#
# Directories

View File

@ -22,18 +22,17 @@ def __initialize_logger():
maxBytes=1024 * 1024,
backupCount=5
)
handlers.append(file_handler)
file_handler.setLevel(dj_settings.LOG_LEVEL)
file_handler.setFormatter(logging.Formatter(dj_settings.LOG_FORMAT))
logging.root.addHandler(file_handler)
logging.root.setLevel(dj_settings.LOG_LEVEL)
if dj_settings.DEBUG:
console_handler = logging.StreamHandler(stream=sys.stdout)
console_handler.setLevel(logging.DEBUG)
handlers.append(console_handler)
console_handler.setFormatter(logging.Formatter(dj_settings.CONSOLE_LOG_FORMAT))
logging.root.addHandler(console_handler)
logging.basicConfig(
level=dj_settings.LOG_LEVEL,
format=dj_settings.LOG_FORMAT,
handlers=handlers
)
def main():