Skip to main content

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

Installation

pip install structlogx

Usage

import logging
from json_logger 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 .

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

structlogx-0.1.1.tar.gz (3.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

structlogx-0.1.1-py3-none-any.whl (3.5 kB view details)

Uploaded Python 3

File details

Details for the file structlogx-0.1.1.tar.gz.

File metadata

  • Download URL: structlogx-0.1.1.tar.gz
  • Upload date:
  • Size: 3.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.11

File hashes

Hashes for structlogx-0.1.1.tar.gz
Algorithm Hash digest
SHA256 23ddfed37028a05522db9d291433a60c216a4783de2538be05be43bbc4148dbf
MD5 5ddf87f1f40bd4277a65332c32f594a0
BLAKE2b-256 857820bdef3f05daccdc216a8a15ed928b5294c6dd33709a65ffa91afa201e46

See more details on using hashes here.

File details

Details for the file structlogx-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: structlogx-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 3.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.11

File hashes

Hashes for structlogx-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 6a4b9d82bcb4404bfdcb2cab9c8914be3133f93f8ba0a69ab4ef94f32031c8e3
MD5 b4720692977d2f4cb2801e12432dde9d
BLAKE2b-256 e2f4c69c6bfa36e534c6db4a571ecf9deff6c5d6945ac68d1c77471f7e52d2b5

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page