sane date format for django.server

This commit is contained in:
Christoph J. Scherr 2023-06-04 00:13:05 +02:00
parent 630d150bcc
commit 77ad852bf8
Signed by: PlexSheep
GPG Key ID: 25B4ACF7D88186CC
1 changed files with 12 additions and 8 deletions

View File

@ -15,6 +15,7 @@ import os
# default django # default django
from pathlib import Path from pathlib import Path
from django.utils.log import ServerFormatter
# Build paths inside the project like this: BASE_DIR / 'subdir'. # Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent BASE_DIR = Path(__file__).resolve().parent.parent
@ -172,6 +173,9 @@ DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
import logging import logging
myServerFormatter = ServerFormatter
myServerFormatter.default_time_format = "%Y-%M-%d %H:%M:%S"
LOGGING = { LOGGING = {
"version": 1, "version": 1,
"disable_existing_loggers": False, "disable_existing_loggers": False,
@ -185,27 +189,27 @@ LOGGING = {
}, },
"formatters": { "formatters": {
"django.server": { "django.server": {
"()": "django.utils.log.ServerFormatter", "()": "gawa.settings.myServerFormatter",
'format': '[{levelname}][{name}][{server_time}] "{message}"', 'format': '[{asctime}][{levelname}][{name}] {message}',
"style": "{", "style": "{",
}, },
'verbose': { 'verbose': {
'format': '[{asctime}][{levelname}][{name}] "{message}"', 'format': '[{asctime}][{levelname}][{name}] {message}',
'style': '{', 'style': '{',
}, },
'mail': { 'mail': {
'level': 'DEBUG', 'level': 'DEBUG',
'format': '[{asctime}][{levelname}][{name}]\n"{message}"', 'format': '[{asctime}][{levelname}][{name}]\n\n{message}',
'style': '{', 'style': '{',
}, },
'simple': { 'simple': {
'level': 'DEBUG', 'level': 'DEBUG',
'format': '[{levelname}][{name}] "{message}"', 'format': '[{levelname}][{name}] {message}',
'style': '{', 'style': '{',
}, },
'fancym': { 'fancym': {
'()': 'colorlog.ColoredFormatter', '()': 'colorlog.ColoredFormatter',
'format': '%(log_color)s[%(asctime)s][%(levelname)s][%(name)s]:\n[%(message)s]', 'format': '%(log_color)s[%(asctime)s][%(levelname)s][%(name)s]\n[%(message)s]',
'log_colors': { 'log_colors': {
'DEBUG': 'cyan', 'DEBUG': 'cyan',
'INFO': 'green', 'INFO': 'green',
@ -216,7 +220,7 @@ LOGGING = {
}, },
'fancy': { 'fancy': {
'()': 'colorlog.ColoredFormatter', '()': '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': { 'log_colors': {
'DEBUG': 'cyan', 'DEBUG': 'cyan',
'INFO': 'green', 'INFO': 'green',
@ -227,7 +231,7 @@ LOGGING = {
}, },
'fancy_internal': { 'fancy_internal': {
'()': 'colorlog.ColoredFormatter', '()': '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': { 'log_colors': {
'DEBUG': 'thin_cyan', 'DEBUG': 'thin_cyan',
'INFO': 'thin_green', 'INFO': 'thin_green',