General purpose logging utility library
Project description
Log-Schema
This logging utility library utilizes python's standard logging library and logging.config to help setup logging. Use the command below to easily setup logging for a project.
Usage
The default setup for logging adheres to the best practice guidelines described here.
import log_schema
import logging
log_schema.setup_logging()
logging.info("Hello")
# Output: {"timestamp": "2026-04-08T22:58:22.677137Z", "level": "INFO", "message": "Hello"}
The examples directory in this project contains additional examples on other features such as:
- Setup logging from a config (logging.config)
- Setup logging with dynamic fields
- Adding additional handlers with correct format
Implementation Notes
-
If using a custom config file, the fields in
modelwill overwrite the static_fields set in the config ONLY IF the formatters explicitly referencelog_schema.DefaultFormatterAND contains the same field key. -
Each handler has its own formatter. Any additional handlers added to the root logger needs to redefine the formatter. This can easily be done by using the
DefaultFormatterwith the samemodelused for setup. Alternatively, you can make new models for different handlers.new_handler.setFormatter(DefaultFormatter(models="<whatever model used for setup"))
Local Development
cd python
uv sync
uv run src/log_schema/main.py
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 log_schema-0.2.10.dev1.tar.gz.
File metadata
- Download URL: log_schema-0.2.10.dev1.tar.gz
- Upload date:
- Size: 3.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
68c4994c0f105d83c6018c11e71a4d092606b06d90d5ba71e28bd827054e7b4e
|
|
| MD5 |
90a1380a026303fab36c7d3a58db847b
|
|
| BLAKE2b-256 |
b5e6d60ad510b2b57127fae677f5ce3d0beda8700418a64340c14653c97d5bcb
|
File details
Details for the file log_schema-0.2.10.dev1-py3-none-any.whl.
File metadata
- Download URL: log_schema-0.2.10.dev1-py3-none-any.whl
- Upload date:
- Size: 5.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
52ea47aac71db15bab7bbccf3077425aade5c67795925ddc98b4901f26c56f11
|
|
| MD5 |
bdca3c792ba503a2e581a0646b2a6e5e
|
|
| BLAKE2b-256 |
d85ed51bdec2f143dd1997565c2bb8163c7aa83f8d8ce84d50da55fbb5005b39
|