mirror of
https://github.com/rommapp/romm.git
synced 2026-11-29 01:58:41 +01:00
The linter ran over every Markdown file and Python comment, so full-repo trunk runs on master kept failing on em-dashes that predate it. Replace the existing ones once and drop the check. The AGENTS.md rule stays, the v2 ESLint rule stays, and pr-ready's humanizer pass catches new ones in prose. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RyamrxVw5BzEidVzm68LY7
42 lines
1.3 KiB
Python
42 lines
1.3 KiB
Python
from fastapi import HTTPException, Request, status
|
|
|
|
from config import DISABLE_LOGS_VIEWER
|
|
from decorators.auth import protected_route
|
|
from endpoints.responses.log import LogEntrySchema
|
|
from endpoints.sockets.logs import get_recent_logs
|
|
from handler.auth.constants import Scope
|
|
from logger.log_stream_handler import LOG_BUFFER_SIZE
|
|
from utils.router import APIRouter
|
|
|
|
router = APIRouter(
|
|
prefix="/logs",
|
|
tags=["logs"],
|
|
)
|
|
|
|
# Largest backfill the buffer holds, derived from the producer's ring buffer
|
|
# so the two never drift.
|
|
MAX_LOG_LIMIT = LOG_BUFFER_SIZE
|
|
|
|
|
|
@protected_route(router.get, "", [Scope.LOGS_READ])
|
|
async def get_logs(
|
|
request: Request, limit: int = MAX_LOG_LIMIT
|
|
) -> list[LogEntrySchema]:
|
|
"""Return the most recent backend log lines for backfill (admin only).
|
|
|
|
Args:
|
|
request (Request): FastAPI Request object.
|
|
limit (int): Maximum number of recent lines to return.
|
|
|
|
Returns:
|
|
list[LogEntrySchema]: Recent log lines, oldest-first.
|
|
"""
|
|
if DISABLE_LOGS_VIEWER:
|
|
raise HTTPException(
|
|
status_code=status.HTTP_404_NOT_FOUND, detail="Logs viewer is disabled"
|
|
)
|
|
|
|
bounded = max(1, min(limit, MAX_LOG_LIMIT))
|
|
entries = await get_recent_logs(bounded)
|
|
return [LogEntrySchema(**entry) for entry in entries]
|