feat: better logging

This commit is contained in:
2026-04-12 14:55:47 +02:00
parent 64adac02a2
commit cd81abf785
11 changed files with 208 additions and 41 deletions
+6 -3
View File
@@ -1,11 +1,14 @@
import logging
from . import params, page, data_dir
class Registry:
def __init__(self, params: params.Parameters):
self.logger = logging.getLogger(self.__class__.__name__)
self.pages: dict[str, page.Page] = {}
self.data_dir = data_dir.DataDir(params.data_dir)
self.prefix = f"http://{params.host}:{params.port}"
self.prefix = f"http://{params.host}"
def load_pages(self):
self.pages = {}
@@ -16,7 +19,7 @@ class Registry:
self.pages[path] = page.Page(
path, self.data_dir.has_index(path), self.data_dir.get_host(path)
)
print("Updated: " + self.prefix + str(self.pages[path]))
self.logger.info("Updated %s%s", self.prefix, str(self.pages[path]))
def set_host(self, path: str, host: str):
self.data_dir.set_host(path, host)
@@ -25,7 +28,7 @@ class Registry:
def remove(self, path: str):
page = self.pages[path]
del self.pages[path]
print("Removed: " + self.prefix + str(page))
self.logger.info("Removed %s%s", self.prefix, str(page))
def get_from_host(self, host: str) -> page.Page | None:
for p in self.pages.values():