Skip to main content

Add support for using t-strings for logging

Project description

tstringlogger

[!WARNING] This is just an early prototype of an idea based on reading PEP 750. I might rewrite it, abandon it, or completely delete it - do not rely on it in any way.

Adds support for using t-strings in log messages while preserving all interpolated values.

Usage example:

>>> import logging
>>> test1, test2 = "A", "B"
>>>
>>> logging.error(t"{test1=}, {test2}")
ERROR:root:Template(strings=('test1=', ', ', ''), interpolations=(Interpolation...
>>>
>>> import tstringlogger
>>> tstringlogger.enable()  # automatically adds t-string support to stdlib logging
>>>
>>> logging.error(t"{test1=}, {test2}")
ERROR:root:test1='A', B

In this example the LogRecord that was produced will have the data that was interpolated into the message available as record.args. In the above example the data would be: {"test1": "A", "test2": "B"}

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

tstringlogger-1.0.0.tar.gz (2.0 kB view details)

Uploaded Source

Built Distribution

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

tstringlogger-1.0.0-py3-none-any.whl (2.2 kB view details)

Uploaded Python 3

File details

Details for the file tstringlogger-1.0.0.tar.gz.

File metadata

  • Download URL: tstringlogger-1.0.0.tar.gz
  • Upload date:
  • Size: 2.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.7.6

File hashes

Hashes for tstringlogger-1.0.0.tar.gz
Algorithm Hash digest
SHA256 cf05e5d24bc7dcd68a0fafcbb65e0184d13556ab7d5f4c1aa69057207a73ccb6
MD5 4919d782c2423010e2e71b9a908bed06
BLAKE2b-256 ecfc05107bc26ac8b816e89ba9cc185517977879aa7c7ceecf0eb95c1377f7a7

See more details on using hashes here.

File details

Details for the file tstringlogger-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for tstringlogger-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a6cf2f1e37b6701918dddbbf743202ba76db502890854ebdf8d61a71c473a5a0
MD5 951f1ef2601c1fdb903e8cefba25daf0
BLAKE2b-256 9c5cc90393b989e4f8ffe55a86ccddc1c310010c660d02fcf2bf28670ed147ef

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