Skip to main content

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_LEVEL environment variable
  • ✅ Zero external dependencies beyond python-json-logger
  • ✅ Drop-in replacement for standard logging module

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

Metadata

Release files for structlogx 0.1.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for structlogx 0.1.3
File Size Uploaded Provenance Actions
structlogx-0.1.3.tar.gz 4.0 kB Without provenance Details for structlogx-0.1.3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for structlogx 0.1.3
File Interpreter ABI Platform Actions
structlogx-0.1.3-py3-none-any.whl Python 3 none any Details for structlogx-0.1.3-py3-none-any.whl

Total release size: 8.2 kB

Release files / structlogx-0.1.3.tar.gz

Download URL structlogx-0.1.3.tar.gz
Size 4.0 kB
Tags Source
SHA-256 checksum
How to use checksums
adc8d0dcc220a536c990708bd79a96088ede7b6f70e051531c5d835f7add7286
BLAKE2b-256 checksum
How to use checksums
18a4b161c061f59e3e0caad4f2f7ed058f618935232f1ffd334f336930fdf6f7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.11

Release files / structlogx-0.1.3-py3-none-any.whl

Download URL structlogx-0.1.3-py3-none-any.whl
Size 4.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
21efa9bb409fc0ce9612bdffa22fa09af9b270268b83c863f0588ec0cc2bb7d7
BLAKE2b-256 checksum
How to use checksums
56a650a6e21ced76f3326630239a671170cdf420ff746cc3a34c436a1ee82597
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.11

Security for structlogx 0.1.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page