Skip to main content

Module logging

Module logging 

Source
Expand description

SQLite-backed request logging.

Every proxied request is logged to a SQLite database with its timestamp, method, domain, path, action (allow/deny/ask/system-allow), and reason. The database is accessed through an r2d2 connection pool (DbPool) for thread-safe concurrent writes from async tasks.

The export submodule provides JSON and CSV export of all logs.

Modules§

export
Log export in JSON and CSV formats.

Structs§

LogEvent
A real-time log event broadcast to subscribers (e.g., web dashboard SSE).
LogFilter
Filter criteria for log queries.
RequestLog
A single logged request record stored in the requests table.
RequestStats
Aggregated request statistics from the requests table.
TimelineBucket
A single bucket in the timeline aggregation.

Functions§

init_db
Initialize the SQLite database and create the requests table if it doesn’t exist. Also runs migrations to add audit columns if they are missing.
log_request
Log a request to the database.
open_db
Open or create a SQLite database at the given path.
open_memory_db
Open an in-memory SQLite database (for testing).
open_memory_pool
Open an in-memory connection pool (for testing).
open_pool
Open a connection pool for the given database file path.
query_filtered
Query logs with flexible filters. All filters are combined with AND.
query_recent
Query the most recent N log entries.
query_stats
Query aggregated request counts grouped by action.
query_timeline
Query bucketed request counts per minute over the last N minutes.

Type Aliases§

DbPool
SQLite connection pool type alias (r2d2 + r2d2-sqlite).