Improve logging
This commit is contained in:
parent
0d7b2a4935
commit
741baa3c7a
|
@ -10,6 +10,10 @@ For the full list of settings and their values, see
|
|||
https://docs.djangoproject.com/en/4.0/ref/settings/
|
||||
"""
|
||||
|
||||
import os
|
||||
import logging.config
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
from pathlib import Path
|
||||
|
||||
# Build paths inside the project like this: BASE_DIR / 'subdir'.
|
||||
|
@ -22,8 +26,8 @@ BASE_DIR = Path(__file__).resolve().parent.parent
|
|||
# SECURITY WARNING: keep the secret key used in production secret!
|
||||
SECRET_KEY = 'django-insecure-au(y+z)$-iy#(obif&ilg*_pn0j_+0u=q*p7h(3c-ii-euncwx'
|
||||
|
||||
# SECURITY WARNING: don't run with debug turned on in production!
|
||||
DEBUG = True
|
||||
DEBUG_ENV = os.environ.get('DEBUG', False)
|
||||
DEBUG = DEBUG_ENV or False
|
||||
|
||||
ALLOWED_HOSTS = [
|
||||
'api.soak.stctech.ca',
|
||||
|
@ -40,6 +44,8 @@ INSTALLED_APPS = [
|
|||
'django.contrib.messages',
|
||||
'django.contrib.staticfiles',
|
||||
'rest_framework',
|
||||
#'rest_framework.authtoken',
|
||||
#'apiserver.api',
|
||||
]
|
||||
|
||||
MIDDLEWARE = [
|
||||
|
@ -127,3 +133,43 @@ STATIC_URL = 'static/'
|
|||
# https://docs.djangoproject.com/en/4.0/ref/settings/#default-auto-field
|
||||
|
||||
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
|
||||
|
||||
LOGGING = {
|
||||
'version': 1,
|
||||
'disable_existing_loggers': False,
|
||||
'formatters': {
|
||||
'medium': {
|
||||
'format': '[%(asctime)s] [%(process)d] [%(levelname)7s] %(message)s'
|
||||
},
|
||||
},
|
||||
'filters': {
|
||||
},
|
||||
'handlers': {
|
||||
'console': {
|
||||
'level': 'DEBUG',
|
||||
'filters': [],
|
||||
'class': 'logging.StreamHandler',
|
||||
'formatter': 'medium'
|
||||
},
|
||||
},
|
||||
'loggers': {
|
||||
'gunicorn': {
|
||||
'handlers': ['console'],
|
||||
'level': 'DEBUG' if DEBUG else 'INFO',
|
||||
'propagate': False,
|
||||
},
|
||||
'': {
|
||||
'handlers': ['console'],
|
||||
'level': 'DEBUG',
|
||||
'propagate': True,
|
||||
},
|
||||
},
|
||||
'root': {
|
||||
'level': 'DEBUG' if DEBUG else 'INFO',
|
||||
'handlers': ['console'],
|
||||
},
|
||||
}
|
||||
logging.config.dictConfig(LOGGING)
|
||||
|
||||
if DEBUG: logger.info('Debug mode ON')
|
||||
logger.info('Test logging for each thread')
|
||||
|
|
Loading…
Reference in New Issue
Block a user