from __future__ import annotations

from datetime import datetime

from pydantic import BaseModel, Field


class SystemLogFileRead(BaseModel):
    name: str
    size_bytes: int = 0
    updated_at: datetime | None = None


class SystemLogTailRead(BaseModel):
    name: str
    size_bytes: int = 0
    updated_at: datetime | None = None
    line_count: int = 0
    lines: list[str] = Field(default_factory=list)


class SystemLogEntryRead(BaseModel):
    id: str
    source_file: str
    line_number: int = 0
    timestamp: datetime | None = None
    level: str = "UNKNOWN"
    logger: str = ""
    message: str = ""
    request_id: str = ""
    method: str = ""
    path: str = ""
    status_code: int | None = None
    duration_ms: float | None = None
    event_type: str = "系统日志"
    outcome: str = "未知"
    summary: str = ""
    parse_status: str = "parsed"
    raw: str = ""
