Skip to main content

A tiny zero-cost debugging helper for Python

Project description

zdbg

A zero-cost library for printing debugging and error messages from Python programs that is trivial to use, while also giving you the following.

  • Per-stream output selection (errors and debugging messages).
  • Color-tagged labels.
  • Optional timestamps and file context information.
  • Zero-cost disable path (via rebinding debug to a no-op).
  • Atomic thread-safe reconfiguration.
  • Optional stream flush behavior.
  • No handler objects, logger objects, format strings, or logger factories.
  • A single configure() function determining all output behavior.
  • NO additional dependencies beyond the standard Python libraries.

How simple is zdbg to use? The following is an example.

import zdbg

if __name__ == "__main__":
    zdbg.debug("Starting")
    zdbg.error("Nothing to do")
    zdbg.debug("Stopping")

Put the above in ztest.py and then try the following.

$ python3 ./ztest.py
Error: Nothing to do

$ DEBUG=debug python3 ./ztest.py
DEBUG: Starting
Error: Nothing to do
DEBUG: Stopping

$ DEBUG=debug,context python3 ./ztest.py
DEBUG: ./ztest.py:8: Starting
Error: ./ztest.py:9: Nothing to do
DEBUG: ./ztest.py:10: Stopping

Screenshot of shell interaction

The format of the error context string makes it clickable in many tools, including Visual Studio Code.

Why zdbg

I wanted something simple with zero overhead when debugging is disabled, without other dependencies, and with configurability without having to do a lot of work up front to get things working.

If that sounds good, then Welcome!

zdbg uses Semantic Versioning.

Bugs?

Have you found a bug? Submit it through the [zdbg Issues][] tracker, and be sure to include (1) what happens, (2) what you expect to happen, (3) how to reproduce the bug, and (4) what version of zdbg you are using.

Minimum Supported Python Version

See pyproject.toml.

Security

Please submit sensitive security issues using the "This issue is confidential..." button below the issue description field in the issue tracker.

Contribute

See [Contributing][] for information about contributing to this project.

Copyright

zdbg is Copyright (c) by Stacy Prowell mailto:sprowell+zdbg@gmail.com. All rights reserved. See the LICENSE file for more information.

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

zdbg-1.0.0.tar.gz (8.6 kB view details)

Uploaded Source

Built Distribution

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

zdbg-1.0.0-py3-none-any.whl (7.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: zdbg-1.0.0.tar.gz
  • Upload date:
  • Size: 8.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.5

File hashes

Hashes for zdbg-1.0.0.tar.gz
Algorithm Hash digest
SHA256 f6fa43dd650388d9228387f8ba9322bdff134a0a4e23ff3823f970b3cd01783a
MD5 efca41df38abe7652d0e04c3406ee857
BLAKE2b-256 cb14b7be51a8c89dbd3ddb40aa1e91f8f4dc02e11bb3da179cdcc909f22ec02d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: zdbg-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 7.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.5

File hashes

Hashes for zdbg-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ed18224dd9ba30f392b99aeb1a154f894f11a4e975f9750a5d180276bf81d61f
MD5 56b9f8dd88ac2e22fec8515c1ea73aed
BLAKE2b-256 3d174e0ace7dd675a284ad523928653651011b6f91136500b92f6d1eda35cac0

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