From 12fbbcedf8c025f0b97ed82720867f7fd0de21fa Mon Sep 17 00:00:00 2001 From: Dirk Alders Date: Mon, 7 Oct 2024 16:48:03 +0200 Subject: [PATCH] Logging for own loggers enabled in config --- piki/settings.py | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/piki/settings.py b/piki/settings.py index 5477021..89eb5a6 100644 --- a/piki/settings.py +++ b/piki/settings.py @@ -148,6 +148,43 @@ USE_I18N = True USE_TZ = True +# Logging Configuration +# +LOGGING = { + 'version': 1, + 'disable_existing_loggers': False, + 'formatters': { + 'short': { + 'format': "%(name)25s - %(levelname)10s - %(message)s", + 'datefmt': '[%d/%b/%Y %H:%M:%S]', + }, + 'long': { + 'format': """~~~~(%(levelname)-10s)~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +File "%(pathname)s", line %(lineno)d, in %(funcName)s +%(asctime)s: %(name)s - %(message)s +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~""", + }, + }, + 'handlers': { + 'console': { + 'level': 'DEBUG', + 'class': 'logging.StreamHandler', + 'formatter': 'short', + }, + }, + 'loggers': { + 'django': { + 'handlers': ['console'], + 'level': 'INFO', + 'propagate': False, + }, + ROOT_LOGGER_NAME: { + 'handlers': ['console'], + 'level': 'DEBUG' if DEBUG else 'INFO', + 'propagate': False, + }, + }, +} # Static files (CSS, JavaScript, Images) # https://docs.djangoproject.com/en/5.1/howto/static-files/