Context-aware CLI logging and display toolkit using Rich and SQLite.
Project description
Context-Aware Logging CLI Framework
A modular, context-aware logging framework for CLI applications written in Python — powered by Rich for beautiful output, and SQLite for persistent logging.
Includes full context stack management, secure state control via tokens, and structured log export features.
🔥 Features
- ✅ Rich-based CLI logging with color, level, and formatting
- ✅ Context-managed debug/log/database state (
SysContext) - ✅ Secure token-authenticated argument context (
ArgsContext) - ✅ Stack-based context separation (supports nesting)
- ✅ SQLite-based log storage with automatic DB lifecycle
- ✅ Export to JSON or CSV via CLI
- ✅ Modular class architecture (SRP & SOLID-principled)
- ✅ Zero external dependencies beyond
rich
📦 Project Structure
src/
├── display/
│ ├── core/ # Display & LogControl core classes
│ ├── database/ # SQLite backend logic
│ ├── exporters/ # CSV / JSON log exporters
│ ├── utils/ # Custom formatters
│ └── state.py # Token-based context stack management
├── run.py # Entry point
🚀 Getting Started
1. Create & activate a virtual environment
python3 -m venv .venv
source .venv/bin/activate
2. Install dependencies
pip install -r requirements.txt
3. Run the CLI
python src/run.py
🛠 CLI Options
usage: run.py [-h] [-c] [-dbp DB_PATH] [-db] [-d] [-gl GET_LOGS] [-ll LOG_LEVEL] [-e EXPORT]
optional arguments:
-c, --clear Clear the database
-dbp, --db_path Specify database path (default: logs.db)
-db, --db Enable logging to database
-d, --debug Enable debug mode
-gl, --get-logs Fetch logs from the database (by level)
-ll, --log-level Set logging level (10-DEBUG, 20-INFO, 30-ERROR, etc.)
-e, --export Export logs to file (json or csv)
-h, --help Show this help message and exit
📚 Examples Log to console only:
python src/run.py
Log to console and database, then export:
python src/run.py --db --export json
Fetch logs at INFO level (20):
python src/run.py --get-logs 20
🔐 Context Management
Both SysContext and ArgsContext are stack-based and protected by secure tokens managed by AuthManager.
This ensures:
-
Separation of concerns
-
Predictable behavior in nested or concurrent executions
-
Strict token-bound lifecycle handling
Testing & Extensibility
Unit tests can easily be written by mocking LogDB, AuthManager, or wrapping Display in test contexts.
The framework is highly extensible — just plug in new exporters, replace the storage backend, or integrate with other services.
✨ Credits
Created by someone who got up too early and had too much time to think. 😉 If you find this useful, please consider giving it a star! ⭐️
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file richdisplay-0.1.0.tar.gz.
File metadata
- Download URL: richdisplay-0.1.0.tar.gz
- Upload date:
- Size: 18.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
77822235aa94d3e5a0ffb2e53be3afeee932376e094c3b148c0127cb59792df3
|
|
| MD5 |
bb7c91e32705a58ed5327c33b63e60ea
|
|
| BLAKE2b-256 |
ab251460de22166f1c68b91d27b27c5b4dae7a9c424ca0cb9db0dc3b86634ba4
|
File details
Details for the file richdisplay-0.1.0-py3-none-any.whl.
File metadata
- Download URL: richdisplay-0.1.0-py3-none-any.whl
- Upload date:
- Size: 20.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
80ef53b280686488e5b35d6500935b9871cabdba3ead4dc6d1e82a085e5a92f7
|
|
| MD5 |
d657a617bd859967c8c592a06822b4e9
|
|
| BLAKE2b-256 |
e6de58610340dd11a59bba3b8478c9f19ab1a951895720c75a5f9a4dfccfd611
|