diff --git a/paskia/db/background.py b/paskia/db/background.py index 381d67e..7b07dbd 100644 --- a/paskia/db/background.py +++ b/paskia/db/background.py @@ -87,6 +87,7 @@ async def start_background(): global _background_task if _background_task is None: _background_task = asyncio.create_task(_background_loop()) + _logger.info("Database background task started") async def stop_background(): diff --git a/paskia/db/jsonl.py b/paskia/db/jsonl.py index 2dff383..1b61d8f 100644 --- a/paskia/db/jsonl.py +++ b/paskia/db/jsonl.py @@ -119,6 +119,9 @@ async def flush_changes( # Append all lines in a single write (binary mode for Windows compatibility) async with aiofiles.open(db_path, "ab") as f: await f.write(b"\n".join(lines) + b"\n") + _logger.debug( + "Flushed %d change(s) to %s", len(changes_to_write), db_path + ) return True except OSError: _logger.exception("Failed to flush database changes") diff --git a/paskia/db/operations.py b/paskia/db/operations.py index db0fbc5..cae5a99 100644 --- a/paskia/db/operations.py +++ b/paskia/db/operations.py @@ -7,6 +7,7 @@ Write operations: Functions that validate and commit, or raise ValueError. """ import hashlib +import logging import os import secrets from collections import deque @@ -18,6 +19,8 @@ from uuid import UUID import msgspec +_logger = logging.getLogger(__name__) + from paskia.db.jsonl import ( DB_PATH_DEFAULT, _ChangeRecord, @@ -98,6 +101,11 @@ class DB: create_change_record(self._current_actor, diff) ) self._previous_builtins = current + _logger.debug( + "Queued change by %s, %d pending", + self._current_actor, + len(self._pending_changes), + ) @contextmanager def transaction(self, actor: str = "system"):