1.6 KiB
1.6 KiB
Issue #10: Advanced Access Logging Implementation
Overview
Implemented a comprehensive access logging system that parses Caddy's structured JSON logs, provides a searchable/filterable UI, and allows for log downloads.
Backend Implementation
- Model:
CaddyAccessLogstruct ininternal/models/log_entry.gomatching Caddy's JSON format. - Service:
LogServiceininternal/services/log_service.goupdated to:- Parse JSON logs line-by-line.
- Support filtering by search term (request/host/client_ip), host, and status code.
- Support pagination.
- Handle legacy/plain text logs gracefully.
- API:
LogsHandlerininternal/api/handlers/logs_handler.goupdated to:- Accept query parameters (
page,limit,search,host,status). - Provide a
Downloadendpoint for raw log files.
- Accept query parameters (
Frontend Implementation
- Components:
LogTable.tsx: Displays logs in a structured table with status badges and duration formatting.LogFilters.tsx: Provides search input and dropdowns for Host and Status filtering.
- Page:
Logs.tsxupdated to integrate the new components and manage state (pagination, filters). - Dependencies: Added
date-fnsfor date formatting.
Verification
- Backend Tests:
go test ./internal/services/... ./internal/api/handlers/...passed. - Frontend Build:
npm run buildpassed. - Manual Check: Verified log parsing and filtering logic via unit tests.
Next Steps
- Ensure Caddy is configured to output JSON logs (already done in previous phases).
- Monitor log file sizes and rotation (handled by
lumberjackin previous phases).