Improved logging

NOTE:
when running without --noreload, there will be two log files, as Django runs two threads to make the auto reloading functionality work.
This commit is contained in:
Corban-Lee Jones 2024-01-16 16:53:27 +00:00
parent b52d1376d2
commit 4c37286b59

View File

@ -3,6 +3,9 @@
import os, environ
from pathlib import Path
from django.utils import timezone
now = timezone.now()
env = environ.Env(
# set casting, default value
DEBUG=(bool, True)
@ -131,11 +134,13 @@ LOGGING = {
'file': {
'level': 'DEBUG',
'class': 'logging.FileHandler',
'filename': LOGGING_DIR / 'debug.log',
'filename': LOGGING_DIR / f'{now}.log',
"formatter": "verbose",
},
'console': {
'level': 'DEBUG',
'class': 'logging.StreamHandler',
"formatter": "verbose"
},
},
'loggers': {
@ -144,7 +149,22 @@ LOGGING = {
'level': 'INFO',
'propagate': True,
},
"django.request": {
"handlers": ["file", "console"],
"level": "ERROR",
"propagate": True
},
"": {
"handlers": ["file", "console"],
"level": "DEBUG",
"propagate": True
}
},
"formatters": {
"verbose": {
"format": "[%(asctime)s] [%(levelname)s] [%(name)s]: %(message)s" # [%(asctime)s] [%(levelname)s] [%(name)s]: %(message)s
}
}
}
# Internationalization