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
Von PyPI (empfohlen):
pip install hmlogger
Lokal aus dem Repository:
pip install -e .
Mit Test-Abhaengigkeiten:
pip install -e .[test]
Nach der Installation:
from HmLogger import setup_logging, get_logger
import logging
setup_logging(level=logging.INFO)
log = get_logger(__name__)
log.info("Hello World")
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()
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.
Tests
Tests liegen im Ordner tests/.
python -m pytest
Die Test-Abhaengigkeiten sind als optionales Extra test in pyproject.toml hinterlegt.
CI
Ein GitHub-Actions-Workflow unter .github/workflows/ci.yml fuehrt die Tests bei Push und Pull Requests nach main auf Python 3.11 bis 3.13 aus.
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.2.tar.gz.
File metadata
- Download URL: hmlogger-0.0.2.tar.gz
- Upload date:
- Size: 9.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8e25fa33e374be9651d6af4382f79e8542865e5772ccfdabcc927cdf247d3916
|
|
| MD5 |
e376f236a5c628de6f02d1f240ffa9cd
|
|
| BLAKE2b-256 |
2d0ede89b7c656da7a256b881a8913abfde6bc71339b197ddaa284a9564dcd07
|
File details
Details for the file hmlogger-0.0.2-py3-none-any.whl.
File metadata
- Download URL: hmlogger-0.0.2-py3-none-any.whl
- Upload date:
- Size: 9.5 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 |
240227fb075b070ee61e675f1d38c7f7d39230cc40026bb64a17b0d7337e3b9d
|
|
| MD5 |
572009021d2675ca9cd75f83518d1d40
|
|
| BLAKE2b-256 |
fcd0b23ddf943b810c99ceac338cd6d29cab75b0c735399492dda4e5ea5410bf
|