Uniform JSON logging for University Medicine Essen (UME)
Project description
UME Logging (logging-ume)
Uniform JSON logging for University Medicine Essen applications.
Features
- JSON log output (Docker/K8s/ELK friendly)
- App/env/service/request context injection
- PII scrubbing (emails, numeric IDs, phone numbers)
- OpenTelemetry trace/span IDs in logs
- Optional log→OTel span event bridge
- FastAPI middleware for request/response logging
- Compatible with Python 3.9+
📦 Installation
pip install logging-ume
# Optional extras:
pip install "logging-ume[fastapi]" # FastAPI request logging middleware
pip install "logging-ume[otel]" # OpenTelemetry tracing + span events
🚀 Quickstart
import logging
from umelogging import log_configure
log_configure("INFO", app="dicom2fhir", env="prod", service="mapping")
log = logging.getLogger(__name__)
log.info("Starting dicom-to-fhir mapping job.")
Example Output (JSON):
{
"time": "2025-08-12T12:01:23.456Z",
"level": "INFO",
"logger": "myapp",
"message": "Starting dicom-to-fhir mapping job.",
"org": "UME",
"app": "dicom2fhir",
"env": "prod",
"service": "mapping"
}
⚙️ Environment Variables
| Variable | Description | Default |
|---|---|---|
UME_LOG_LEVEL |
Logging level | INFO |
UME_APP |
App name | |
UME_ENV |
Environment (prod, dev, test) | prod |
UME_SERVICE |
Service name | |
UME_COMPONENT |
Component/module name | |
UME_USER_HASH_SALT |
Salt for user ID hashing | ume |
UME_OTEL_SPAN_EVENTS |
Mirror logs as OTel span events | false |
🌐 FastAPI Integration (optional)
Add request/response logging to your FastAPI app:
from fastapi import FastAPI
from umelogging.fastapi.middleware import UMELoggingMiddleware
app = FastAPI()
app.add_middleware(UMELoggingMiddleware)
This will log incoming requests and responses in JSON, including request ID, latency, status, and correlation information.
📈 OpenTelemetry Integration (optional)
Enable OpenTelemetry tracing and span events in your logs:
from umelogging import log_configure
log_configure(
"INFO",
app="myapp",
env="prod",
otel_enable=True, # Enable OpenTelemetry
otel_exporter="otlp", # or "console"
)
Configure via environment variables:
| Variable | Description | Example |
|---|---|---|
UMELOG_OTEL_ENABLE |
Enable OTel tracing/log bridge | true |
UMELOG_OTEL_EXPORTER |
OTel exporter ("otlp", "console") | otlp |
OTEL_EXPORTER_OTLP_ENDPOINT |
OTel collector endpoint | http://otel:4317 |
See OpenTelemetry Docs for advanced setup.
📄 License
MIT License.
Copyright © University Medicine Essen ZIT / IKIM.
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 ume_logging-0.0.11.tar.gz.
File metadata
- Download URL: ume_logging-0.0.11.tar.gz
- Upload date:
- Size: 4.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
98321247b4ec486ce95b89d6c7a585ef18ffccd2dedd71a5158002996c403e98
|
|
| MD5 |
8aae702488b0900ee74d8d5f90d6ae83
|
|
| BLAKE2b-256 |
95aad8e23f047a8066ffa514a09ac0b5979c5b516bc386f878cde04ab3e12c95
|
Provenance
The following attestation bundles were made for ume_logging-0.0.11.tar.gz:
Publisher:
python-publish.yml on UMEssen/ume-logging
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ume_logging-0.0.11.tar.gz -
Subject digest:
98321247b4ec486ce95b89d6c7a585ef18ffccd2dedd71a5158002996c403e98 - Sigstore transparency entry: 384885259
- Sigstore integration time:
-
Permalink:
UMEssen/ume-logging@301ce89b42f102c8e4ff9de6d5e516efcc51b48a -
Branch / Tag:
refs/tags/0.0.11 - Owner: https://github.com/UMEssen
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@301ce89b42f102c8e4ff9de6d5e516efcc51b48a -
Trigger Event:
release
-
Statement type:
File details
Details for the file ume_logging-0.0.11-py3-none-any.whl.
File metadata
- Download URL: ume_logging-0.0.11-py3-none-any.whl
- Upload date:
- Size: 5.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
02bc46fdd12e1b4b9da895f6f50e626d4c523a2d2df7dbcd2d5abcd293418cf2
|
|
| MD5 |
7b912297eeae9aa2e14794a96e95ae17
|
|
| BLAKE2b-256 |
68cef1f68e282bf4af9e798d5f913bf6bb9fcfa12d1d8ade592449046c4e3da6
|
Provenance
The following attestation bundles were made for ume_logging-0.0.11-py3-none-any.whl:
Publisher:
python-publish.yml on UMEssen/ume-logging
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ume_logging-0.0.11-py3-none-any.whl -
Subject digest:
02bc46fdd12e1b4b9da895f6f50e626d4c523a2d2df7dbcd2d5abcd293418cf2 - Sigstore transparency entry: 384885263
- Sigstore integration time:
-
Permalink:
UMEssen/ume-logging@301ce89b42f102c8e4ff9de6d5e516efcc51b48a -
Branch / Tag:
refs/tags/0.0.11 - Owner: https://github.com/UMEssen
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@301ce89b42f102c8e4ff9de6d5e516efcc51b48a -
Trigger Event:
release
-
Statement type: