Skip to main content

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.

Richdisplay Logo


🔥 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

🐍 Dependencies

  • rich (for beautiful CLI output)

That's it. No SQLAlchemy. No pandas. No click. No nonsense. All other functionality — token management, argument parsing, DB logging, exporting — is written in clean, native Python.

🚀 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

richdisplay-0.2.0.tar.gz (19.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

richdisplay-0.2.0-py3-none-any.whl (21.3 kB view details)

Uploaded Python 3

File details

Details for the file richdisplay-0.2.0.tar.gz.

File metadata

  • Download URL: richdisplay-0.2.0.tar.gz
  • Upload date:
  • Size: 19.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.2

File hashes

Hashes for richdisplay-0.2.0.tar.gz
Algorithm Hash digest
SHA256 3b0e3d4e32fef9bf3cbcb5966efd0d6f0c20aa7b73a9e2fbbcf11bb017fd795c
MD5 3459e481b74b1f34f1ba90290afbb764
BLAKE2b-256 db317332a627c76c80eb1e8c3718f1ff216a211fab6032c07593b8dedf460dea

See more details on using hashes here.

File details

Details for the file richdisplay-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: richdisplay-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 21.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.2

File hashes

Hashes for richdisplay-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0c9485e74772e7a2246b8006a08b9a7136e93efb541595982b9f0b660e558eaf
MD5 fb1b90dc442e78676ffa85a6df12afa8
BLAKE2b-256 13a71ae4e82c7f469cd322b9b1e37f325cdb696d40353a2875de87946594b6d4

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page