libLogit is not only about writing logs. The Alpha and Beta product direction is that logs should still be useful after the process exits.
Today, the Python reference binding proves that story with a local SQLite store
and the liblogit-viewer tool.
Use the SQLite plus viewer workflow when you want:
Enable the database sink and point it at a local SQLite file:
{
"name": "AuditLog",
"databasePath": "logs/audit.sqlite",
"sinks": ["console", "database"],
"retention": {
"maxRecords": 10000
}
}
Or do the same thing directly in Python:
from liblogit import INFO, LOGIT
AuditLog = LOGIT({
"name": "AuditLog",
"databasePath": "logs/audit.sqlite",
"sinks": ["console", "database"],
"retention": {"maxRecords": 10000},
})
AuditLog.log(INFO, "database-backed event")
The repository includes a direct example:
That script:
LOGITLOGITsqlite3The current Alpha SQLite store is intended to be queried with standard SQL tools. The important working assumption for Beta docs is simple:
.sqlite fileThe deeper schema contract continues to live in spec/log-store.md and the Python implementation.
These queries are meant to get a developer oriented quickly.
SELECT sequence, created_at, logger, level, message
FROM logit_events
ORDER BY sequence DESC
LIMIT 25;
SELECT created_at, logger, level, message
FROM logit_events
WHERE logger = 'AuditLog'
ORDER BY sequence DESC
LIMIT 50;
SELECT created_at, logger, level, message
FROM logit_events
WHERE level IN ('error', 'fatal')
ORDER BY sequence DESC;
SELECT created_at, logger, level, message
FROM logit_events
WHERE message LIKE '%signed in%'
ORDER BY sequence DESC;
SELECT created_at, logger, level, metadata_json
FROM logit_events
WHERE metadata_json IS NOT NULL
ORDER BY sequence DESC
LIMIT 25;
Any SQLite-capable tool should work. Common choices include:
sqlite3 command-line clientThe product point is that libLogit should not require a special server or cloud service just to read local retained logs.
The current Python reference package also exposes a viewer command:
liblogit-viewer logs/audit.sqlite
There is also a query-friendly CLI mode:
python -m liblogit.viewer logs/audit.sqlite --print --level info --limit 20
The viewer direction for Beta is:
The current Python reference implementation supports bounded retention for the SQLite sink with:
retention.maxRecordsretention.maxAgeSecondsretention.maxBytesThose settings are the current Alpha proof of the “round robin” retained-store idea: keep the most useful recent history and evict older data according to a defined policy.
Be plain about the current state: