From 630d150bcc4279f135d40291ff5d0a5fc7ae0bc2 Mon Sep 17 00:00:00 2001 From: PlexSheep Date: Sat, 3 Jun 2023 23:54:11 +0200 Subject: [PATCH] better logging --- .gitignore | 2 ++ gawa/blog/templates/blog/blogpost.html | 42 +++++--------------------- gawa/blog/views.py | 4 ++- gawa/debug.log | 26 ---------------- gawa/errors.log | 12 -------- gawa/gawa/settings.py | 14 ++++----- gawa/start/templates/base.html | 2 ++ 7 files changed, 21 insertions(+), 81 deletions(-) delete mode 100644 gawa/debug.log delete mode 100644 gawa/errors.log diff --git a/.gitignore b/.gitignore index 731713b..3b459bc 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,5 @@ db/data gawa/gawa/__pycache__ gawa/start/__pycache__ gawa/blog/__pycache__ +gawa/debug.log +gawa/errors.log diff --git a/gawa/blog/templates/blog/blogpost.html b/gawa/blog/templates/blog/blogpost.html index f81dcf7..3695786 100644 --- a/gawa/blog/templates/blog/blogpost.html +++ b/gawa/blog/templates/blog/blogpost.html @@ -4,49 +4,21 @@ {% block languagecode %}{{ LANGUAGE_CODE }}{% endblock languagecode %} {% block title %}{% translate "cscherr.de" %} - {% translate "Blog" %}{% endblock title %} {% block nav %} - {% include 'blog/nav.html' %} +{% include 'blog/nav.html' %} {% endblock nav %} +{% block headscripts %} + +{% endblock headscripts %} {% block main %}

{{ post.title }}

{% translate "Blog" %}

-
-
-

{% translate "Writeups" %}

-

- {% blocktranslate %} - Whenever I discover some interesting security thing, I will post a writeup here. - {% endblocktranslate %} -

-
-
-

{% translate "Open Source" %}

- {% blocktranslate %} - If something comes up, I may post Linux guides or my thoughts on current processes here. - {% endblocktranslate %} -
-
-

{% translate "Selfhosting" %}

- {% blocktranslate %} - Selfhosting is something that I'm really fond of. There will be guides and thoughts about that too - {% endblocktranslate %} -
-
-

{% translate "Anything Really" %}

- {% blocktranslate %} - This is my personal Blog after all, I will put here whatever I want and you can't stop me. - {% endblocktranslate %} -
-
- test - sus -
-
-

{% translate "Looking for anything specific?" %}

- {% include 'main_search_form.html' %} + $$x=\frac{-b+\sqrt{b^2-4ac}}{2a}$$
{% include 'blog/featured.html' %}
diff --git a/gawa/blog/views.py b/gawa/blog/views.py index e3f98b7..cfa878f 100644 --- a/gawa/blog/views.py +++ b/gawa/blog/views.py @@ -34,12 +34,14 @@ class Post(DetailView): category__slug=self.kwargs['category'], # first slug is category slug=self.kwargs['slug'] # second slug is article itself ) - logger.critical("hello world") + logger.debug(obj) match get_language(): case 'de': + logger.debug("returning blogpost for de") obj['title'] = obj['title_de'] case 'en': + logger.debug("returning blogpost for en") obj['title'] = obj['title_en'] case _: diff --git a/gawa/debug.log b/gawa/debug.log deleted file mode 100644 index 1ef31ab..0000000 --- a/gawa/debug.log +++ /dev/null @@ -1,26 +0,0 @@ -[TIME[2023-06-03 21:49:51,872] LEVEL[INFO] MODULE[autoreload] NAME[django.utils.autoreload] PID[7] THREAD[140464426821440] MESSAGE[Watching for file changes with StatReloader] -[TIME[2023-06-03 21:58:35,767] LEVEL[INFO] MODULE[autoreload] NAME[django.utils.autoreload] PID[7] THREAD[140464426821440] MESSAGE[/app/gawa/settings.py changed, reloading.] -[TIME[2023-06-03 21:58:36,728] LEVEL[INFO] MODULE[autoreload] NAME[django.utils.autoreload] PID[9] THREAD[140232828950336] MESSAGE[Watching for file changes with StatReloader] -[TIME[2023-06-03 21:58:36,728] LEVEL[INFO] MODULE[autoreload] NAME[django.utils.autoreload] PID[9] THREAD[140232828950336] MESSAGE[Watching for file changes with StatReloader] -[TIME[2023-06-03 21:59:17,277] LEVEL[INFO] MODULE[autoreload] NAME[django.utils.autoreload] PID[9] THREAD[140232828950336] MESSAGE[/app/gawa/settings.py changed, reloading.] -[TIME[2023-06-03 21:59:17,277] LEVEL[INFO] MODULE[autoreload] NAME[django.utils.autoreload] PID[9] THREAD[140232828950336] MESSAGE[/app/gawa/settings.py changed, reloading.] -[TIME[2023-06-03 21:59:18,370] LEVEL[INFO] MODULE[autoreload] NAME[django.utils.autoreload] PID[11] THREAD[140632004777792] MESSAGE[Watching for file changes with StatReloader] -[TIME[2023-06-03 21:59:18,370] LEVEL[INFO] MODULE[autoreload] NAME[django.utils.autoreload] PID[11] THREAD[140632004777792] MESSAGE[Watching for file changes with StatReloader] -[TIME[2023-06-03 21:59:26,361] LEVEL[WARNING] MODULE[log] NAME[django.request] PID[11] THREAD[140631958742784] MESSAGE[Not Found: /ensd/blog/test/test] -[TIME[2023-06-03 21:59:26,361] LEVEL[WARNING] MODULE[log] NAME[django.request] PID[11] THREAD[140631958742784] MESSAGE[Not Found: /ensd/blog/test/test] -[TIME[2023-06-03 21:59:26,363] LEVEL[WARNING] MODULE[basehttp] NAME[django.server] PID[11] THREAD[140631958742784] MESSAGE["GET /ensd/blog/test/test HTTP/1.1" 404 2230] -[TIME[2023-06-03 21:59:26,592] LEVEL[WARNING] MODULE[log] NAME[django.request] PID[11] THREAD[140631958742784] MESSAGE[Not Found: /favicon.ico] -[TIME[2023-06-03 21:59:26,592] LEVEL[WARNING] MODULE[log] NAME[django.request] PID[11] THREAD[140631958742784] MESSAGE[Not Found: /favicon.ico] -[TIME[2023-06-03 21:59:26,593] LEVEL[WARNING] MODULE[basehttp] NAME[django.server] PID[11] THREAD[140631958742784] MESSAGE["GET /favicon.ico HTTP/1.1" 404 2206] -[TIME[2023-06-03 21:59:58,471] LEVEL[WARNING] MODULE[log] NAME[django.request] PID[11] THREAD[140631958742784] MESSAGE[Not Found: /ensd/blog/test/test] -[TIME[2023-06-03 21:59:58,471] LEVEL[WARNING] MODULE[log] NAME[django.request] PID[11] THREAD[140631958742784] MESSAGE[Not Found: /ensd/blog/test/test] -[TIME[2023-06-03 21:59:58,474] LEVEL[WARNING] MODULE[basehttp] NAME[django.server] PID[11] THREAD[140631958742784] MESSAGE["GET /ensd/blog/test/test HTTP/1.1" 404 2230] -[TIME[2023-06-03 21:59:58,903] LEVEL[WARNING] MODULE[log] NAME[django.request] PID[11] THREAD[140631958742784] MESSAGE[Not Found: /favicon.ico] -[TIME[2023-06-03 21:59:58,903] LEVEL[WARNING] MODULE[log] NAME[django.request] PID[11] THREAD[140631958742784] MESSAGE[Not Found: /favicon.ico] -[TIME[2023-06-03 21:59:58,907] LEVEL[WARNING] MODULE[basehttp] NAME[django.server] PID[11] THREAD[140631958742784] MESSAGE["GET /favicon.ico HTTP/1.1" 404 2206] -[TIME[2023-06-03 22:00:28,959] LEVEL[WARNING] MODULE[log] NAME[django.request] PID[11] THREAD[140631958742784] MESSAGE[Not Found: /ensd/blog/test/test] -[TIME[2023-06-03 22:00:28,959] LEVEL[WARNING] MODULE[log] NAME[django.request] PID[11] THREAD[140631958742784] MESSAGE[Not Found: /ensd/blog/test/test] -[TIME[2023-06-03 22:00:28,960] LEVEL[WARNING] MODULE[basehttp] NAME[django.server] PID[11] THREAD[140631958742784] MESSAGE["GET /ensd/blog/test/test HTTP/1.1" 404 2230] -[TIME[2023-06-03 22:00:29,473] LEVEL[WARNING] MODULE[log] NAME[django.request] PID[11] THREAD[140631958742784] MESSAGE[Not Found: /favicon.ico] -[TIME[2023-06-03 22:00:29,473] LEVEL[WARNING] MODULE[log] NAME[django.request] PID[11] THREAD[140631958742784] MESSAGE[Not Found: /favicon.ico] -[TIME[2023-06-03 22:00:29,474] LEVEL[WARNING] MODULE[basehttp] NAME[django.server] PID[11] THREAD[140631958742784] MESSAGE["GET /favicon.ico HTTP/1.1" 404 2206] diff --git a/gawa/errors.log b/gawa/errors.log deleted file mode 100644 index 4d0a912..0000000 --- a/gawa/errors.log +++ /dev/null @@ -1,12 +0,0 @@ -[TIME[2023-06-03 21:59:26,361] LEVEL[WARNING] MODULE[log] NAME[django.request] PID[11] THREAD[140631958742784] MESSAGE[Not Found: /ensd/blog/test/test] -[TIME[2023-06-03 21:59:26,361] LEVEL[WARNING] MODULE[log] NAME[django.request] PID[11] THREAD[140631958742784] MESSAGE[Not Found: /ensd/blog/test/test] -[TIME[2023-06-03 21:59:26,592] LEVEL[WARNING] MODULE[log] NAME[django.request] PID[11] THREAD[140631958742784] MESSAGE[Not Found: /favicon.ico] -[TIME[2023-06-03 21:59:26,592] LEVEL[WARNING] MODULE[log] NAME[django.request] PID[11] THREAD[140631958742784] MESSAGE[Not Found: /favicon.ico] -[TIME[2023-06-03 21:59:58,471] LEVEL[WARNING] MODULE[log] NAME[django.request] PID[11] THREAD[140631958742784] MESSAGE[Not Found: /ensd/blog/test/test] -[TIME[2023-06-03 21:59:58,471] LEVEL[WARNING] MODULE[log] NAME[django.request] PID[11] THREAD[140631958742784] MESSAGE[Not Found: /ensd/blog/test/test] -[TIME[2023-06-03 21:59:58,903] LEVEL[WARNING] MODULE[log] NAME[django.request] PID[11] THREAD[140631958742784] MESSAGE[Not Found: /favicon.ico] -[TIME[2023-06-03 21:59:58,903] LEVEL[WARNING] MODULE[log] NAME[django.request] PID[11] THREAD[140631958742784] MESSAGE[Not Found: /favicon.ico] -[TIME[2023-06-03 22:00:28,959] LEVEL[WARNING] MODULE[log] NAME[django.request] PID[11] THREAD[140631958742784] MESSAGE[Not Found: /ensd/blog/test/test] -[TIME[2023-06-03 22:00:28,959] LEVEL[WARNING] MODULE[log] NAME[django.request] PID[11] THREAD[140631958742784] MESSAGE[Not Found: /ensd/blog/test/test] -[TIME[2023-06-03 22:00:29,473] LEVEL[WARNING] MODULE[log] NAME[django.request] PID[11] THREAD[140631958742784] MESSAGE[Not Found: /favicon.ico] -[TIME[2023-06-03 22:00:29,473] LEVEL[WARNING] MODULE[log] NAME[django.request] PID[11] THREAD[140631958742784] MESSAGE[Not Found: /favicon.ico] diff --git a/gawa/gawa/settings.py b/gawa/gawa/settings.py index 43f39db..3551256 100644 --- a/gawa/gawa/settings.py +++ b/gawa/gawa/settings.py @@ -186,21 +186,21 @@ LOGGING = { "formatters": { "django.server": { "()": "django.utils.log.ServerFormatter", - "format": "[{server_time}] {message}", + 'format': '[{levelname}][{name}][{server_time}] "{message}"', "style": "{", }, 'verbose': { - 'format': '[TIME[{asctime}] LEVEL[{levelname}] MODULE[{module}] NAME[{name}] PID[{process:d}] THREAD[{thread:d}] MESSAGE[{message}]', + 'format': '[{asctime}][{levelname}][{name}] "{message}"', 'style': '{', }, 'mail': { 'level': 'DEBUG', - 'format': 'TIME[{asctime}] LEVEL[{levelname}] MODULE[{module}] NAME[{name}] PID[{process:d}] THREAD[{thread:d}]\nMESSAGE[{message}]', + 'format': '[{asctime}][{levelname}][{name}]\n"{message}"', 'style': '{', }, 'simple': { 'level': 'DEBUG', - 'format': '{levelname} {message}', + 'format': '[{levelname}][{name}] "{message}"', 'style': '{', }, 'fancym': { @@ -216,7 +216,7 @@ LOGGING = { }, 'fancy': { '()': 'colorlog.ColoredFormatter', - 'format': '%(log_color)s[%(asctime)s][%(levelname)s][%(name)s][%(message)s]', + 'format': '%(log_color)s[%(asctime)s][%(levelname)s][%(name)s] "%(message)s"', 'log_colors': { 'DEBUG': 'cyan', 'INFO': 'green', @@ -227,7 +227,7 @@ LOGGING = { }, 'fancy_internal': { '()': 'colorlog.ColoredFormatter', - 'format': '%(log_color)s[%(asctime)s][%(levelname)s][%(name)s][%(message)s]', + 'format': '%(log_color)s[%(asctime)s][%(levelname)s][%(name)s] "%(message)s"', 'log_colors': { 'DEBUG': 'thin_cyan', 'INFO': 'thin_green', @@ -242,7 +242,7 @@ LOGGING = { "level": "INFO", "filters": ["require_debug_true"], "class": "logging.StreamHandler", - "formatter": "fancym", + "formatter": "fancy", }, "django.server": { "level": "INFO", diff --git a/gawa/start/templates/base.html b/gawa/start/templates/base.html index db828b1..ae10d1e 100644 --- a/gawa/start/templates/base.html +++ b/gawa/start/templates/base.html @@ -18,6 +18,8 @@ } setTheme(localStorage.getItem('theme')); + {% block headscripts %} + {% endblock headscripts %} {% block nav %}