Skip to main content

Python Logging Helpers

Project description

ot-logging-helpers

This python package provides logging helpers that are used in Orthanc Team projects.

Demo

from ot_logging_helpers import LogContext, configure_logging
import logging
import threading

configure_logging()

with LogContext("1ST"):
    logging.info("my first message")
    with LogContext("2ND"):
        logging.info("my second message")


def worker(worker_id):
    with LogContext(f"Worker {worker_id}"):
        logging.info("my top level worker message")

        with LogContext("next-context"):
            logging.warning("my warning")

for i in range(0, 2):
    thread = threading.Thread(target=worker, args=(i+1, ))
    thread.start()


###### this shall output 
# 2024-04-05 15:05:28,162 - root       - INFO     -  1ST | my first message
# 2024-04-05 15:05:28,162 - root       - INFO     -  1ST | 2ND | my second message
# 2024-04-05 15:05:28,163 - root       - INFO     -  Worker 1 | my top level worker message
# 2024-04-05 15:05:28,163 - root       - WARNING  -  Worker 1 | next-context | my warning
# 2024-04-05 15:05:28,163 - root       - INFO     -  Worker 2 | my top level worker message
# 2024-04-05 15:05:28,163 - root       - WARNING  -  Worker 2 | next-context | my warning

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

ot_logging_helpers-0.1.0.tar.gz (5.2 kB view details)

Uploaded Source

Built Distribution

ot_logging_helpers-0.1.0-py3-none-any.whl (3.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: ot_logging_helpers-0.1.0.tar.gz
  • Upload date:
  • Size: 5.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.0.0 CPython/3.12.2

File hashes

Hashes for ot_logging_helpers-0.1.0.tar.gz
Algorithm Hash digest
SHA256 ba99abb48fa37718b5b5d0632b08d179c7822ce9d1a60d47d56a8e5d8223b169
MD5 be09f45e7a81d12a348a0d1773471243
BLAKE2b-256 6406a24d4c80ecd51dbeb2224b35a4f8c26029b0d37be5eefdb68e8eb25fb1b5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ot_logging_helpers-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f9a7773fe83a65e179e2d8ee2b0a42622656af7c9e45425d3758960fc4143da6
MD5 d9103f65e4eeff456007bb9ceec9250e
BLAKE2b-256 ffebeca37d767875ffe3fe53a13deb6ad014b61a368586b9b4580e600569d7d6

See more details on using hashes here.

Supported by

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