Skip to main content

A logging example application with sudo detection and log rotation

Project description

LoggedExample

LoggedExample is a clean, minimal demonstration application built to showcase ChronicleLogger — a high-performance, POSIX-compliant, cross-version (Python 2.7 & 3.x) logging utility with daily rotation, automatic archiving (tar.gz >7 days), old log removal (>30 days), privilege-aware paths (/var/log for root, ~/.app for users), and smart environment detection (venv, pyenv, pyenv-virtualenv, Miniconda/Anaconda).

ChronicleLogger is available on PyPI: https://pypi.org/project/ChronicleLogger/

LoggedExample PyPI: https://pypi.org/project/LoggedExample/

Current version: 1.1.1

Features

  • Uses ChronicleLogger for structured, timestamped logging: [YYYY-MM-DD HH:MM:SS] pid:<PID> [<LEVEL>] @<COMPONENT> :] <MESSAGE>
  • Automatically adapts log/base directory based on:
    • Active Python environment (venv / pyenv / pyenv-virtualenv / miniconda)
    • User privileges (root vs non-root)
  • Debug mode (DEBUG=show) displays complete logger + environment information
  • Simple CLI interface (LoggedExample info)
  • Zero external dependencies beyond ChronicleLogger
  • Ready for development, containers, or system services

Installation

Quick install (global or current environment)

pip install LoggedExample

Run:

LoggedExample info
# With full debug output:
DEBUG=show LoggedExample info

Recommended: Use an isolated environment

LoggedExample (powered by ChronicleLogger) detects the active Python environment and places logs inside it — usually under <env>/.app/logged-example/log/ or ~/.app/logged-example/log/.


Environment Guide: Purpose, Installation & Usage (2025)

Environment Purpose Log Location (non-root) Log Location (root) Best For
venv Built-in, lightweight, project-specific isolation <venv>/.app/logged-example/log/ /var/log/logged-example/ Quick projects, CI/CD, simple teams
pyenv Manage multiple Python versions easily on one system ~/.pyenv/versions/3.12/.app/logged-example/log/ /var/log/logged-example/ Developers switching Python versions
pyenv + virtualenv Best of both worlds: version + project isolation ~/.pyenv/versions/<env-name>/.app/logged-example/log/ /var/log/logged-example/ Recommended for most developers
Miniconda Lightweight Conda distribution — fast, minimal, scientific-friendly ~/miniconda3/envs/<name>/.app/logged-example/log/ /var/log/logged-example/ Data science, ML, reproducible envs
Anaconda Full-featured Conda with hundreds of preinstalled packages ~/anaconda3/envs/<name>/.app/logged-example/log/ /var/log/logged-example/ Beginners in data/science, heavy deps

1. venv (standard Python virtual environment)

python3 -m venv logged-env
source logged-env/bin/activate

pip install LoggedExample

DEBUG=show LoggedExample info

2. pyenv (multiple Python versions)

pyenv install 3.12
pyenv global 3.12               # or pyenv local 3.12

pip install LoggedExample

DEBUG=show LoggedExample info

3. pyenv + virtualenv plugin (recommended)

pyenv virtualenv 3.12 logged-example-env
pyenv activate logged-example-env

pip install LoggedExample

DEBUG=show LoggedExample info

4. Miniconda (lightweight Conda)

conda create -n logged-example python=3.12
conda activate logged-example

pip install LoggedExample

DEBUG=show LoggedExample info

5. Anaconda (full distribution)

conda create -n logged-example python=3.12
conda activate logged-example

pip install LoggedExample

DEBUG=show logged-example info

Root / System-wide Usage

sudo -E DEBUG=show logged-example info          # via sudo → user home
sudo su -                                       # real root
DEBUG=show LoggedExample info                  # → /var/log/logged-example/

Development / From Source

git clone https://github.com/yourusername/logged-example.git
cd logged-example

pyenv virtualenv 3.12 logged-example-dev
pyenv activate logged-example-dev

pip install -e .

License

MIT

Made with ❤️ using ChronicleLogger — happy logging!

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

loggedexample-1.2.2.tar.gz (5.2 kB view details)

Uploaded Source

Built Distribution

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

loggedexample-1.2.2-py3-none-any.whl (5.6 kB view details)

Uploaded Python 3

File details

Details for the file loggedexample-1.2.2.tar.gz.

File metadata

  • Download URL: loggedexample-1.2.2.tar.gz
  • Upload date:
  • Size: 5.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for loggedexample-1.2.2.tar.gz
Algorithm Hash digest
SHA256 7c26674bb76c90781985af56f7921ed7750fac2052f862917abef3c5bf2d2797
MD5 815b041fb5e6a2095120f9746ce1284a
BLAKE2b-256 92fcec412958d4243c05712e1679f8eb3828853b3c55816673029be6fc15d495

See more details on using hashes here.

File details

Details for the file loggedexample-1.2.2-py3-none-any.whl.

File metadata

  • Download URL: loggedexample-1.2.2-py3-none-any.whl
  • Upload date:
  • Size: 5.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for loggedexample-1.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 0ca46dba5300cde1904323b1f51bef500a75194cc7f51b1618caf4fb9ebd94cc
MD5 a08e03d4ff1620df4a1d89c9dff1967f
BLAKE2b-256 00fa5ff2d5c863b2355ca4531b68037ba725859b6571584444d1036b062945a3

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