Adaption to new logging

This commit is contained in:
Dirk Alders 2021-01-21 19:38:10 +01:00
parent 0e7664e059
commit 3a94e857aa
11 changed files with 55 additions and 58 deletions

23
.gitignore vendored
View File

@ -1,6 +1,7 @@
config.py config.py
data/ data/
venv
.settings .settings
# ---> Python # ---> Python
@ -119,3 +120,25 @@ dmypy.json
# Pyre type checker # Pyre type checker
.pyre/ .pyre/
# ---> Linux
*~
# temporary files which can be created if a process still has a handle open of a deleted file
.fuse_hidden*
# KDE directory preferences
.directory
# Linux trash folder which might appear on any partition or disk
.Trash-*
# .nfs files are created when an open file is removed but is still being accessed
.nfs*
# ---> Backup
*.bak
*.gho
*.ori
*.orig
*.tmp

View File

@ -6,6 +6,9 @@ BASE_DIR = os.path.dirname(os.path.abspath(__file__))
# General settings # General settings
# #
# APP_NAME is used for logging
APP_NAME = 'pygal'
# SECURITY WARNING: don't run with debug turned on in production! # SECURITY WARNING: don't run with debug turned on in production!
# DEBUG = False # DEBUG = False

@ -1 +1 @@
Subproject commit ada1f74d4c05a35bad9d2b258f3d0b4ccdfd1653 Subproject commit f5da43b01631147dace87242a94227acfb3e9bc5

2
geo

@ -1 +1 @@
Subproject commit f59b19ed1fd2a64735ca477fdb1fba24681e8879 Subproject commit 11166bb27ad2335f7812fcb88c788397f5106751

View File

@ -11,11 +11,17 @@ https://docs.djangoproject.com/en/3.0/ref/settings/
""" """
import config import config
from logging.handlers import SocketHandler as _SocketHandler
import os import os
import stat import stat
import sys import sys
import random import random
try:
from config import APP_NAME as ROOT_LOGGER_NAME
except ImportError:
ROOT_LOGGER_NAME = 'root'
# Build paths inside the project like this: os.path.join(BASE_DIR, ...) # Build paths inside the project like this: os.path.join(BASE_DIR, ...)
# #
@ -64,7 +70,7 @@ for property_name in USER_CONFIG_DEFAULTS:
if SECRET_KEY is None: if SECRET_KEY is None:
chars = 'abcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*(-_=+)' chars = 'abcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*(-_=+)'
s_key = ''.join([random.choice(chars) for n in range(50)]) s_key = ''.join([random.choice(chars) for n in range(50)])
secret_key_warning = "You need to create a config.py file including at least a SECRET_KEY definition (e.g.: %s)." % repr(s_key) secret_key_warning = "You need to create a config.py file including at least a SECRET_KEY definition (e.g.: --> %s <--)." % repr(s_key)
raise KeyError(secret_key_warning) raise KeyError(secret_key_warning)
@ -194,7 +200,14 @@ PERSISTENT_SESSION_VARIABLES = [SESSION_KEY_THUMBNAIL_SIZE, SESSION_KEY_WEBNAIL_
# Logging Configuration # Logging Configuration
# #
default_handler = ['console_long'] 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 = { LOGGING = {
'version': 1, 'version': 1,
@ -217,46 +230,22 @@ File "%(pathname)s", line %(lineno)d, in %(funcName)s
'class': 'logging.StreamHandler', 'class': 'logging.StreamHandler',
'formatter': 'short', 'formatter': 'short',
}, },
'console_long': { 'socket': {
'level': 'DEBUG', 'level': 'DEBUG',
'class': 'logging.StreamHandler', 'class': 'main.settings.DjangoSocketHandler',
'formatter': 'long', 'host': '127.0.0.1',
'port': 19996,
}, },
}, },
'loggers': { 'loggers': {
'AUTH': { 'django': {
'handlers': default_handler, 'handlers': default_handler,
'level': 'INFO', 'level': 'INFO',
'propagate': False, 'propagate': False,
}, },
'APP': { ROOT_LOGGER_NAME: {
'handlers': default_handler, 'handlers': default_handler,
'level': 'INFO', 'level': 'DEBUG' if DEBUG else 'INFO',
'propagate': False,
},
'CACHING': {
'handlers': default_handler,
'level': 'INFO',
'propagate': False,
},
'WHOOSH': {
'handlers': default_handler,
'level': 'INFO',
'propagate': False,
},
'FSTOOLS': {
'handlers': default_handler,
'level': 'INFO',
'propagate': False,
},
'GEO': {
'handlers': default_handler,
'level': 'INFO',
'propagate': False,
},
'MEDIA': {
'handlers': default_handler,
'level': 'INFO',
'propagate': False, 'propagate': False,
}, },
}, },

2
media

@ -1 +1 @@
Subproject commit 0a67ebeb4810eb00f422745b4a21ee420fc31c85 Subproject commit abcf63d02e866c3832d014c54f2a95acdfb7d304

@ -1 +1 @@
Subproject commit dd0edc2d56c2c234be32fa76e3bd5b6b4f38a69f Subproject commit 5f30383c83b0ea94341b999c489a34f2e7d57f80

2
pygal

@ -1 +1 @@
Subproject commit 84206862234752932d7c30daf82807c1e9fff67a Subproject commit 114a82e1768d3fbf8a83afb61b2f19c271b8868b

View File

@ -1,18 +0,0 @@
1. Setupt venev
* virtualenv -p /usr/bin/python3 pygal-venv
* ln -s pygal-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. python manage.py migrate
3. python manage.py createsuperuser
4. Set SECRET:KEY in config.py
5. Set ITEM_ROOT in config.py to your item target path, otherwise the example_data is used
6. python manage.py collectstatic
7. chgrp www-data . && chmod 770 .
8. chgrp www-data db.sqlite3 && chmod 664 db.sqlite3
9. chgrp www-data -R data
9.1. find data -type d -exec chmod 775 "{}" \;
9.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

@ -1 +1 @@
Subproject commit d5f9931bcab942ac84d8f09b1559995da0d2676c Subproject commit c1d9cf49c34cc6c97cfb372eec4a30f0188181f9

2
users

@ -1 +1 @@
Subproject commit 8cf64464ba094df60fe81442dd0d728075368344 Subproject commit 0827a5311fdbbef689365c6db5762881e048ba9c