Lightweight Python logger with colored output, rotating file logging, and optional async queue logging.
Project description
HmLogger
Ein leichtgewichtiges Logging-Modul fuer Python mit:
- farbiger Konsolen-Ausgabe
- optionalem Rotating-File-Logging
- optionalem asynchronen Logging ueber QueueHandler und QueueListener
Voraussetzungen
- Python 3.11 oder neuer
Hinweis: Das Projekt verwendet typing.Self und Union-Typen mit |.
Installation (lokal)
Direkt aus dem Repository:
pip install -e .
Bis zur PyPI-Veroeffentlichung kann das Modul lokal so verwendet werden:
import HmLogger
Schnellstart
import logging
from HmLogger import setup_logging, get_logger
setup_logging(
level=logging.DEBUG,
use_colors=True,
file_logging=True,
async_logging=True,
)
log = get_logger("App")
log.debug("Debug-Nachricht")
log.info("Info-Nachricht")
log.warning("Warnung")
log.error("Fehler")
log.critical("Kritischer Fehler")
API
setup_logging(...)
setup_logging(
level=logging.INFO,
use_colors=True,
file_logging=True,
async_logging=True,
log_folder="./logs",
log_file="app.log",
mb=5,
backup_count=5,
)
Parameter:
- level: Log-Level (z. B. logging.DEBUG)
- use_colors: ANSI-Farben fuer Konsole aktivieren
- file_logging: Log-Ausgabe in Datei aktivieren
- async_logging: Queue-basiertes, nicht blockierendes Logging
- log_folder: Zielordner fuer Log-Dateien
- log_file: Dateiname der Haupt-Logdatei
- mb: maximale Dateigroesse in MB vor Rotation
- backup_count: Anzahl aufbewahrter Rotationsdateien
get_logger(name)
from HmLogger import get_logger
log = get_logger("MyService")
log.info("Service gestartet")
Farben und Styles
from HmLogger import Color, Text
print(Color("green")("Erfolg"))
print(Color("red").bold()("Fehler"))
print(Color("yellow").underline()("Achtung"))
print(Text("Custom Text", Color("magenta").italic()))
Verfuegbare Farben:
- default
- grey
- red
- green
- yellow
- blue
- magenta
- cyan
- white
Verfuegbare Styles:
- bold()
- dim()
- italic()
- underline()
- blink()
- reversed()
- strikethrough()
- intense()
PyPI-Veroeffentlichung (Schritt fuer Schritt)
-
Paket-Metadaten anlegen
- Datei pyproject.toml erstellen
- mind. name, version, description, readme, requires-python, authors setzen
- Build-Backend definieren (z. B. hatchling oder setuptools)
-
Lizenzdatei hinzufuegen
- Datei LICENSE erstellen (z. B. MIT)
- Lizenz in pyproject.toml referenzieren
-
Paketstruktur pruefen
- sicherstellen, dass das importierbare Paket korrekt gefunden wird
- Paketname auf PyPI: hmlogger
- Import-Name im Code: HmLogger
-
Build-Werkzeuge installieren
python -m pip install --upgrade build twine
- Paket bauen
python -m build
Ergebnis liegt in dist/ (sdist und wheel).
- Artefakte pruefen
python -m twine check dist/*
- Test-Upload zu TestPyPI
python -m twine upload --repository testpypi dist/*
- Installation von TestPyPI pruefen
pip install --index-url https://test.pypi.org/simple/ hmlogger
- Upload zu PyPI
python -m twine upload dist/*
- Release taggen
- Version in pyproject.toml erhoehen
- Git-Tag setzen und veroeffentlichen
Hinweise
- Bei aktivem async_logging wird ein QueueListener verwendet und per atexit sauber beendet.
- Bei file_logging=True werden Dateien rotiert, sobald die konfigurierte Groesse erreicht ist.
Lizenz
Dieses Projekt steht unter der MIT License.
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 hmlogger-0.0.1.tar.gz.
File metadata
- Download URL: hmlogger-0.0.1.tar.gz
- Upload date:
- Size: 7.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
736220165a07050477021660ce1e3dc6925c1d64dcbcc299dc42d111f441e51a
|
|
| MD5 |
71c31650d14c3404424b05b0025ab4f4
|
|
| BLAKE2b-256 |
22629653ad3f47716c9315b35db5a53a69aba93041ead30c16d2df962c43e247
|
File details
Details for the file hmlogger-0.0.1-py3-none-any.whl.
File metadata
- Download URL: hmlogger-0.0.1-py3-none-any.whl
- Upload date:
- Size: 8.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3232762fe20e6dc27145a503a355fff9ea87624671d7267683acb662f0ec01ad
|
|
| MD5 |
a03b9645d4608821a2dc37f1d0c20a68
|
|
| BLAKE2b-256 |
ca2d24b9bd28a9f041841c53a05acf0ad1aea8f8203f92bb5998b56af6600489
|