tailer.py #1

  • //
  • p4mona/
  • dev/
  • p4-rca-agent/
  • p4rca/
  • tailer.py
  • View
  • Commits
  • Open Download .zip Download (1 KB)
"""P4LOG file tailing via log2sql subprocess (go-libp4dlog).

Tails P4LOG in real time and emits parsed command records as JSON
into the rolling SQLite window.
"""
from __future__ import annotations

import logging
from pathlib import Path

logger = logging.getLogger(__name__)


class P4LogTailer:
    """Tails a P4LOG file using log2sql (go-libp4dlog) in JSON output mode.

    Prefer shelling out to log2sql over a native Python parser to inherit
    go-libp4dlog's edge-case handling and test coverage.
    """

    def __init__(self, log_path: Path, db_path: Path, log2sql_bin: Path) -> None:
        """
        Args:
            log_path: Path to the P4LOG file to tail.
            db_path: SQLite database path for the rolling window.
            log2sql_bin: Path to the log2sql binary from go-libp4dlog.
        """
        raise NotImplementedError

    def start(self) -> None:
        """Start tailing the log file. Handles log rotation gracefully."""
        raise NotImplementedError

    def stop(self) -> None:
        """Stop tailing and flush any pending records."""
        raise NotImplementedError
# Change User Description Committed
#1 32636 bot_Claude_Anthropic Scaffold p4-rca-agent repo: directory structure, data models, layer stubs, test fixtures, config, docs.
Covers briefing tasks 2 and 3.
#review-32637 @robert_cowham @tom_tyler