Functions to neatly print debug information to the terminal output, well-suited for multithreaded programs.
Project description
DvG_debug_functions
Provides functions for printing debug information to the terminal output.
dprint()
dprint(str_msg, ANSI_color=None)
‘Debug’ print a single line to the terminal with optional ANSI color codes. The line will be terminated with a newline character and the terminal output buffer is forced to flush before and after every print. In addition, if PyQt5 is present in the Python environment, then a mutex lock will be obtained and released again for each dprint execution.
There is a lot of overhead using this print statement, but it is particularly well-suited for multithreaded PyQt programs where multiple threads are each printing information to the same terminal. The dprint() function ensures that each line sent to the terminal will remain as a continious single line, whereas a regular print() statement will likely result in the lines getting mixed up.
tprint()
tprint(str_msg, ANSI_color=None)
Identical to dprint(), but now prepended with a time.perf_counter() timestamp.
print_fancy_traceback()
print_fancy_traceback(err, back=3)
Print an Exception traceback or the current regular call stack to the terminal, using ANSI color codes that mimic the IPython command shell.
- Args:
- err (Exception | str | None):
When err is of type Exception, then an Exception traceback will be printed. When err is of another type, then the current regular call stack will be printed.
- back (int):
Depth of the traceback or call stack to print.
Default: 3
Example output:
Changelog
2.1.0 (2020-07-17)
Improved print_fancy_traceback()
2.0.0 (2020-07-02)
DvG module filenames changed to lowercase
1.1.2 (2020-06-08)
Code style: black
1.1.1 (2020-06-06)
Extended README
1.1.0 (2020-06-04)
Added tprint(…)
0.0.1 (2020-05-13)
First release on PyPI.
Project details
Release history Release notifications | RSS feed
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
Hashes for dvg-debug-functions-2.1.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 30641409997c1aba0c3adbf81ca2a6d9f7b5712973a18c597d71036f0dc0a225 |
|
MD5 | 2c17302340439b9d09fd3dc08ffdd983 |
|
BLAKE2b-256 | 2259fe6d11510e54a3613e14d1de499f9c3611e3f98f426189ba3d146599a7ab |
Hashes for dvg_debug_functions-2.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 73e514af38d8e33af8057a2bf66aafda63a0cd3803736dc0e518f844d48db9b2 |
|
MD5 | a1b6fd7a17f8db710fcf3419df8f7290 |
|
BLAKE2b-256 | 8c9a97d8d87169c4f6fdb7f41ab42efd897d009963c0c41fcb7dc9f5840b2b63 |