From 176794a3fc28fb77d7544227d9ed2dff1e025fd1 Mon Sep 17 00:00:00 2001 From: Dirk Alders Date: Thu, 21 Jan 2021 18:58:24 +0100 Subject: [PATCH] Adaption to new logging --- .gitignore | 2 ++ README.md | 3 +-- main/settings.py | 39 ++++++++++++++++----------------------- mycreole | 2 +- patt | 2 +- readme.txt | 17 ----------------- users | 2 +- 7 files changed, 22 insertions(+), 45 deletions(-) delete mode 100644 readme.txt diff --git a/.gitignore b/.gitignore index 7051fc2..32492c0 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,8 @@ config.py data/ + venv +.settings # ---> Python # Byte-compiled / optimized / DLL files diff --git a/README.md b/README.md index cfb89eb..a35b295 100644 --- a/README.md +++ b/README.md @@ -87,13 +87,12 @@ and set the Variable ALLOWED_HOSTS. Execute python manage.py dumpdata --natural-foreign --natural-primary -e contenttypes -e sessions -e auth.Permission -e sessions patt --indent 2 > dump_patt.json tar -cvzf dump_media.tgz data/media -**Further Files need to be backuped! ** ### Restore Backup source venv/bin/activate -If you are starting with any database, you need to create one +If you are starting without a database, you need to create one python manage.py migrate diff --git a/main/settings.py b/main/settings.py index 544ed43..859ba63 100644 --- a/main/settings.py +++ b/main/settings.py @@ -11,6 +11,7 @@ https://docs.djangoproject.com/en/3.0/ref/settings/ """ import config +from logging.handlers import SocketHandler as _SocketHandler import os import stat import sys @@ -194,8 +195,14 @@ PERSISTENT_SESSION_VARIABLES = [] # Logging Configuration # -debug_handler = 'console' -default_handler = [debug_handler] if DEBUG else ['console'] +class DjangoSocketHandler(_SocketHandler): + def emit(self, record): + if hasattr(record, 'request'): + record.request = None + return super().emit(record) + + +default_handler = ['socket'] if DEBUG else ['console'] # LOGGING = { 'version': 1, @@ -218,36 +225,22 @@ File "%(pathname)s", line %(lineno)d, in %(funcName)s 'class': 'logging.StreamHandler', 'formatter': 'short', }, - 'console_long': { + 'socket': { 'level': 'DEBUG', - 'class': 'logging.StreamHandler', - 'formatter': 'long', + 'class': 'main.settings.DjangoSocketHandler', + 'host': '127.0.0.1', + 'port': 19996, }, }, 'loggers': { - 'AUTH': { + 'django': { 'handlers': default_handler, 'level': 'INFO', 'propagate': False, }, - 'ACC': { + config.APP_NAME: { 'handlers': default_handler, - 'level': 'INFO', - 'propagate': False, - }, - 'APP': { - 'handlers': default_handler, - 'level': 'INFO', - 'propagate': False, - }, - 'WHOOSH': { - 'handlers': default_handler, - 'level': 'INFO', - 'propagate': False, - }, - 'FSTOOLS': { - 'handlers': default_handler, - 'level': 'INFO', + 'level': 'DEBUG' if DEBUG else 'INFO', 'propagate': False, }, }, diff --git a/mycreole b/mycreole index dd0edc2..5f30383 160000 --- a/mycreole +++ b/mycreole @@ -1 +1 @@ -Subproject commit dd0edc2d56c2c234be32fa76e3bd5b6b4f38a69f +Subproject commit 5f30383c83b0ea94341b999c489a34f2e7d57f80 diff --git a/patt b/patt index 63e9af4..be03b65 160000 --- a/patt +++ b/patt @@ -1 +1 @@ -Subproject commit 63e9af4d65a486309e55bb0925866fb1eaec99cb +Subproject commit be03b653ebce2dadb5bfb314e597966751fb9cf7 diff --git a/readme.txt b/readme.txt deleted file mode 100644 index ad78f4c..0000000 --- a/readme.txt +++ /dev/null @@ -1,17 +0,0 @@ -1. Setupt venev - * virtualenv -p /usr/bin/python3 patt-venv - * ln -s patt-venv/bin/activate - * source activate - * Sometimes upgrades are needed: pip list --outdated | cut -d ' ' -f 1 | xargs pip install $1 --upgrade - * pip install -r requirements.txt -2. Set SECRET:KEY in config.py -3. python manage.py migrate -4. python manage.py createsuperuser -5. python manage.py collectstatic -6. chgrp www-data . && chmod 770 . -7. chgrp www-data db.sqlite3 && chmod 664 db.sqlite3 -8. chgrp www-data -R data -8.1. find data -type d -exec chmod 775 "{}" \; -8.2. find data -type f -exec chmod 664 "{}" \; - -x. Run server by command "python manage.py runserver 0.0.0.0:8000" or add App to apache diff --git a/users b/users index 8cf6446..0827a53 160000 --- a/users +++ b/users @@ -1 +1 @@ -Subproject commit 8cf64464ba094df60fe81442dd0d728075368344 +Subproject commit 0827a5311fdbbef689365c6db5762881e048ba9c