diff --git a/.gitignore b/.gitignore index a2942fe..5d32b68 100644 --- a/.gitignore +++ b/.gitignore @@ -5,4 +5,5 @@ db.sqlite3 __pycache__/ identifier.sqlite vk_config.v2.json -crossposting_backend/private/settings.py \ No newline at end of file +crossposting_backend/private/settings.py +logs/ \ No newline at end of file diff --git a/crossposting_backend/private/settings.example.py b/crossposting_backend/private/settings.example.py index d709879..6f51a94 100644 --- a/crossposting_backend/private/settings.example.py +++ b/crossposting_backend/private/settings.example.py @@ -1,7 +1,37 @@ +from os import path +from pathlib import Path + # SECURITY WARNING: don't run with debug turned on in production! DEBUG = False # SECURITY WARNING: keep the secret key used in production secret! SECRET_KEY = 'django-insecure-aaaa' SALT = 'aaaaaaaa' -ALLOWED_HOSTS = [] \ No newline at end of file +ALLOWED_HOSTS = [] + +LOG_DIR = path.join(Path(__file__).resolve().parent.parent.parent, 'logs/') + +LOGGING = { + 'version': 1, + 'disable_existing_loggers': False, + 'formatters': { + 'standard': { + 'format': '%(asctime)s [%(levelname)s]- %(message)s' + } + }, + 'handlers': { + 'file': { + 'level': 'ERROR', + 'class': 'logging.FileHandler', + 'filename': LOG_DIR + 'application.log', + 'formatter': 'standard' + }, + }, + 'loggers': { + 'django': { + 'handlers': ['file'], + 'level': 'ERROR', + 'propagate': True, + }, + }, +}