logenrich v1.0.1
A Python library that augments the standard
loggingmodule with simplified, INI-driven configuration.
Prerequisites
- Python
>=3.14
Installation
pip install logenrich
Usage
Import setup_logger directly from the logenrich package:
from logenrich import setup_logger
logger = setup_logger(__name__)
logger.info("Hello from logenrich!")
setup_logger searches upward from the current working directory for a logging.ini file and caches the resolved path for subsequent calls. If no configuration file is found, it falls back to basicConfig at INFO level.
Optional parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
name |
str |
(required) | Logger name, typically __name__. |
conf_dir |
`str | None` | Current working directory |
log_ini |
`str | None` | "logging.ini" |
Architecture
flowchart TD
A[caller: setup_logger] --> B{cache valid?}
B -- yes --> E[getLogger]
B -- no --> C[_find_logging_ini\nwalk up tree]
C --> D{logging.ini\nfound?}
D -- yes --> F[fileConfig\nload INI]
D -- no --> G[basicConfig\nINFO level]
F --> E
G --> E
E --> H[Logger instance]
Configuration
Place a logging.ini file in your project root. The bundled default configures two handlers:
| Handler | Target | Format |
|---|---|---|
| Console | sys.stderr |
%(asctime)s - %(name)s - %(levelname)s - %(message)s |
| File | logenrich.log |
%(asctime)s [%(levelname)s] %(name)s - %(message)s |
Example logging.ini:
[loggers]
keys=root
[handlers]
keys=consoleHandler,fileHandler
[formatters]
keys=logFormatter,consoleFormatter
[logger_root]
level=INFO
handlers=consoleHandler,fileHandler
[handler_consoleHandler]
class=StreamHandler
formatter=consoleFormatter
args=(sys.stderr,)
[handler_fileHandler]
class=FileHandler
formatter=logFormatter
args=('logenrich.log', 'a')
[formatter_logFormatter]
format=%(asctime)s [%(levelname)s] %(name)s - %(message)s
[formatter_consoleFormatter]
format=%(asctime)s - %(name)s - %(levelname)s - %(message)s
Development
Requires Poetry
2.2.
Setup
poetry install
Running Tests
poetry run pytest --cov=logenrich tests --cov-report html
Formatting and Linting
poetry run black logenrich; poetry run pylint logenrich
Pylint must score 10/10. Minimum test coverage is 80%.
Publishing to PyPI
Prerequisites
- A PyPI account with an API token.
Configure the token
poetry config pypi-token.pypi <your-token>
Build and publish
poetry publish --build
This builds the source distribution and wheel, then uploads them to PyPI in one step.
Note: PyPI releases are immutable. Once a version is published, it cannot be overwritten.
To fix a mistake, yank the release via the PyPI web UI and publish a new version.
Changelog
See CHANGELOG.md for the full version history.
License
MIT
Author
Ronaldo Webb <ron@ronella.xyz>
Release files for logenrich 1.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| logenrich-1.0.1.tar.gz | 4.3 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| logenrich-1.0.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 9.7 kB
Release files / logenrich-1.0.1.tar.gz
| Download URL | logenrich-1.0.1.tar.gz |
|---|---|
| Size | 4.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ff0f282fe6349d0d215a2e1ca87573c03ebbffa5a9b345e0fd0430b1132996fc
|
|
BLAKE2b-256 checksum How to use checksums |
31d517f254fc061dbef24a9b75da4e870eb9a100d89f4f694e8fd80d9dfa2da2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.3.4 CPython/3.14.4 Windows/11
|
Release files / logenrich-1.0.1-py3-none-any.whl
| Download URL | logenrich-1.0.1-py3-none-any.whl |
|---|---|
| Size | 5.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
fee5a0f1a1d87f0b57c14ecf5cc95c41ccf50a1177eedde315c5ee0ea91fc240
|
|
BLAKE2b-256 checksum How to use checksums |
9284b38218f151e48a3d5df3fe59c3ec3c3d7127e40250c81659ccdd1eba8e35
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.3.4 CPython/3.14.4 Windows/11
|