Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add logging configuration #97

Merged
merged 5 commits into from
Sep 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions src/central_command/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"""

import os
import sys

from datetime import timedelta
from pathlib import Path
Expand Down Expand Up @@ -86,6 +87,57 @@
},
]

LOGGING = {
"version": 1,
"disable_existing_loggers": False,
"formatters": {
"standard": {
"format": "[%(asctime)s] %(levelname)s %(name)s: %(message)s",
},
},
"handlers": {
"console": {
"level": "DEBUG",
"class": "logging.StreamHandler",
"formatter": "standard",
"stream": sys.stdout,
}
},
"loggers": {
# root logger
"": {
"handlers": ["console"],
"level": "INFO",
"propagate": True,
},
"django": {
"handlers": ["console"],
"level": "DEBUG",
"propagate": False,
},
"django.db.backends": {
"handlers": ["console"],
"level": "ERROR",
"propagate": False,
},
"django.utils.autoreload": {
"handlers": ["console"],
"level": "WARNING",
"propagate": False,
},
"accounts": {
"handlers": ["console"],
"level": "DEBUG",
"propagate": False,
},
"persistence": {
"handlers": ["console"],
"level": "DEBUG",
"propagate": False,
},
},
}

WSGI_APPLICATION = "central_command.wsgi.application"

# Database
Expand Down
12 changes: 12 additions & 0 deletions src/persistence/admin.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,20 @@
from typing import Tuple

from django.contrib import admin
from django.db.models import Q, QuerySet
from django.http import HttpRequest

from .models import Character


@admin.register(Character)
class CharacterAdminView(admin.ModelAdmin):
readonly_fields = ("character_name", "last_updated")
list_filter = ("character_sheet_version", "account__unique_identifier")
search_fields = ("data__Name__icontains", "account__unique_identifier__icontains", "account__email__icontains")

def get_search_results(self, request: HttpRequest, queryset: QuerySet, search_term: str) -> Tuple[QuerySet, bool]:
queryset, use_distinct = super().get_search_results(request, queryset, search_term)

queryset |= self.model.objects.filter(Q(data__Name__icontains=search_term))
return queryset, use_distinct
Empty file.
2 changes: 1 addition & 1 deletion src/persistence/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class Character(models.Model):
)

def __str__(self):
return f"{self.character_name} by {self.account.unique_identifier}"
return f'"{self.character_name}" by {self.account.unique_identifier}'

@property
def character_name(self) -> str:
Expand Down
Loading