Skip to main content

Structured JSON logger with trace_id, user_id and colored console output.

Project description

traceloggerx

✨ A Python logging utility with colorful console output and structured JSON file logging. Built for real-world debugging and traceability.

PyPI version

Features

  • Colorful console logs using colorlog
  • JSON structured logs with trace_id and user_id
  • Automatic exception capturing via sys.excepthook
  • Easily reusable across different projects

Installation

pip install traceloggerx

Usage

from logutils.logger import set_logger

# Create a logger with a default user_id
logger = set_logger("myapp", json_format=True, extra={"user_id": "anonymous"})

# Add a trace_id dynamically when logging
logger.info("User accessed dashboard", extra={"trace_id": "req-001"})

Example Usage of traceloggerx

This directory contains example scripts demonstrating how to use the traceloggerx logging utility.

Files

  • basic_usage.py Shows the simplest use of the logger with no trace_id or user_id.
  • with_trace_and_user.py Demonstrates how to include custom fields like trace_id and user_id.
  • fastapi_example.py Integrates traceloggerx with a FastAPI web server using middleware.

How to Run

You can run any script directly:

python examples/basic_usage.py

License

MIT

Maintainer

🔗 GitHub: @darams4863 📦 PyPI: traceloggerx

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

traceloggerx-0.1.8.tar.gz (4.5 kB view details)

Uploaded Source

Built Distribution

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

traceloggerx-0.1.8-py3-none-any.whl (5.8 kB view details)

Uploaded Python 3

File details

Details for the file traceloggerx-0.1.8.tar.gz.

File metadata

  • Download URL: traceloggerx-0.1.8.tar.gz
  • Upload date:
  • Size: 4.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.12

File hashes

Hashes for traceloggerx-0.1.8.tar.gz
Algorithm Hash digest
SHA256 a369d31f1fea09dd04a7024daab3e6e1e241e8e55854f21b6be5ea9541e6fcc1
MD5 8fba6b88c088e5e88e5e67dbbbe4aba2
BLAKE2b-256 ec1ab6817e945e5bcea57a91d2004145688cd534fb03916d37489d0adc740f4c

See more details on using hashes here.

File details

Details for the file traceloggerx-0.1.8-py3-none-any.whl.

File metadata

  • Download URL: traceloggerx-0.1.8-py3-none-any.whl
  • Upload date:
  • Size: 5.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.12

File hashes

Hashes for traceloggerx-0.1.8-py3-none-any.whl
Algorithm Hash digest
SHA256 bf1761bc147b4f09ed2151154a0307d5ca70e7c7c3abe7d9ea3123809ee0229c
MD5 41274a70435378deda7f94c5a10f7a7c
BLAKE2b-256 e6f61a9da544c0761444cf37ebccd0d8d6942c019819a924cf9fddd877d1077b

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