A simple Python logging package
Project description
structlogx
A lightweight, production-ready JSON logger for Python with built-in structured logging, epoch timestamps, and source context (filename, line number, function name).
Features
- ✅ Outputs logs in JSON format for easy parsing
- ✅ Automatically includes epoch timestamp (
timestamp) - ✅ Adds source context:
filename,lineno,funcName - ✅ Configurable log level via
LOG_LEVELenvironment variable - ✅ Zero external dependencies beyond
python-json-logger - ✅ Drop-in replacement for standard
loggingmodule
Installation
pip install structlogx
Usage
import logging
from structlogx import init_logger
# Initialize the logger
init_logger()
# Use standard logging
logging.info("User logged in", extra={"user_id": 123})
logging.error("Failed to process request", extra={"error_code": 500})
Output:
{
"timestamp": 1726578901.234,
"levelname": "INFO",
"message": "User logged in",
"filename": "app.py",
"lineno": 10,
"funcName": "login_handler",
"user_id": 123
}
Environment Variables
| Variable | Default | Description |
|---|---|---|
LOG_LEVEL |
INFO |
Set log level: DEBUG, INFO, WARNING, ERROR, CRITICAL |
Development
To install in development mode:
pip install -e .
Building and Publishing
To build and publish this package:
# Install build tools
pip install build twine
# Build the package
python -m build
# Upload to PyPI (requires credentials)
twine upload dist/*
💡 Note: This package depends on
python-jsonlogger. Install it first if not already present:pip install python-json-logger pip install structlogx
License
MIT
Project details
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 structlogx-0.1.3.tar.gz.
File metadata
- Download URL: structlogx-0.1.3.tar.gz
- Upload date:
- Size: 4.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
adc8d0dcc220a536c990708bd79a96088ede7b6f70e051531c5d835f7add7286
|
|
| MD5 |
0266e06fa4f3587ac21f2265ac89d478
|
|
| BLAKE2b-256 |
18a4b161c061f59e3e0caad4f2f7ed058f618935232f1ffd334f336930fdf6f7
|
File details
Details for the file structlogx-0.1.3-py3-none-any.whl.
File metadata
- Download URL: structlogx-0.1.3-py3-none-any.whl
- Upload date:
- Size: 4.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
21efa9bb409fc0ce9612bdffa22fa09af9b270268b83c863f0588ec0cc2bb7d7
|
|
| MD5 |
25c3259bf87265a56806a5d2cacb4bd1
|
|
| BLAKE2b-256 |
56a650a6e21ced76f3326630239a671170cdf420ff746cc3a34c436a1ee82597
|