A tiny (nearly) zero-cost debugging helper for Python
Project description
zdbg
A (nearly) 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
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.
Performance
"Zero cost?" Well... of course not. But as close to that as I think we can get while still having runtime configurability. See the perftest.py script in examples for a simple performance test that shows the relative overhead of different debugging strategies.
Documentation
See the full documentation of zdbg in the docstring for the module, or USAGE.md
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.md 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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file zdbg-1.1.2.tar.gz.
File metadata
- Download URL: zdbg-1.1.2.tar.gz
- Upload date:
- Size: 12.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c1761f1498b65dd71112e17ac23963e8f8a51f94bfd5281ce3f7231956539989
|
|
| MD5 |
b8464a8a3c20ba025e54b0433c17da4f
|
|
| BLAKE2b-256 |
79ad11140502072a32b3ba6d49fd3eb7637040112b2188e2aeb6eda594224653
|
File details
Details for the file zdbg-1.1.2-py3-none-any.whl.
File metadata
- Download URL: zdbg-1.1.2-py3-none-any.whl
- Upload date:
- Size: 10.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cfec1193379a50a9fc558ef58aae042e69810fc5880780eaa96bfca6304d5624
|
|
| MD5 |
0e31d7180965176c143f03e4c39668ce
|
|
| BLAKE2b-256 |
1f5e84c1702ceefc44b5b04064a86fa6e7e3da9e8859a5fa38cc4204fdb91b93
|