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.0.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.0-py3-none-any.whl (3.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: structlogx-0.1.0.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.0.tar.gz
Algorithm Hash digest
SHA256 eaa786b51a4b1644e41730a37e90b38e390b731f2846c0f1f51fb8ee0b3c03a9
MD5 6fca66565d1a975bd5e3676c6530a4a7
BLAKE2b-256 f797bc4589438b5948ea32d35e40b23172b252c05c0b5384b4f1b41b28f08e5f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: structlogx-0.1.0-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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 dc5ca78b58727a043ab648fa50526db60f3472fe021d87c17c7bdf263cca13ea
MD5 1f6f7a082bb79557d17444852ddae9bb
BLAKE2b-256 8ff33f8430a7d069444a5552b4a68028874d26c85866493b0469e02ac0bf913f

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