Debugger Decorator
A simple Python decorator for debugging functions.
Installation
pip install debugger-decorator
Usage
from debugger_decorator import show_information
@show_information()
def my_function(a, b):
return a + b
my_function(1, 2)
This will print information about the function call, its arguments, return value, and execution time.
Parameters
debug(bool, default=True): Enable or disable debugging output.color_scheme(dict, optional): Custom color scheme for terminal output.track_vars(list or str, optional): Variables to track for changes during execution.log_file(str, optional): File path to write output instead of stdout (plain text, no colors).deep_track(bool, default=False): Use deep copying for variable tracking to detect in-place changes.
Variable Tracking
Track changes to specific variables during function execution:
@show_information(track_vars=['result'])
def calculate(x, y):
result = x + y
result *= 2
return result
calculate(3, 4)
For deep tracking of in-place modifications:
@show_information(track_vars=['data'], deep_track=True)
def modify_list(data):
data.append(5) # Detected with deep_track
return data
Output Redirection
Redirect debug output to a file:
@show_information(log_file='debug.log')
def my_function(a, b):
return a + b
my_function(1, 2) # Output to debug.log
Customizing Colors
You can customize the color scheme for better accessibility or personal preference:
from debugger_decorator import show_information
from colorama import Fore, Style, Back
# High contrast color scheme
high_contrast_colors = {
'header': Style.BRIGHT + Fore.WHITE,
'params': Fore.CYAN,
'running': Style.BRIGHT + Fore.YELLOW,
'return': Back.GREEN + Style.BRIGHT + Fore.BLACK,
'time': Style.BRIGHT + Fore.GREEN,
'error': Style.BRIGHT + Fore.RED,
'dashes': Style.BRIGHT + Fore.WHITE,
'error_dashes': Style.BRIGHT + Fore.RED,
'tracking': Style.BRIGHT + Fore.MAGENTA,
}
@show_information(color_scheme=high_contrast_colors)
def my_function(a, b):
return a + b
my_function(1, 2)
Available color keys:
header: Function name and caller infoparams: Parameter names and valuesrunning: "Running . . ." messagereturn: Return value displaytime: Execution timeerror: Error messagesdashes: Separator lineserror_dashes: Error separator linestracking: Variable change messages
Uses Colorama styles (DIM, NORMAL, BRIGHT) and colors (Fore., Back., Style.*).
Error Handling
The decorator catches and displays exceptions with colors:
@show_information()
def failing_function():
raise ValueError("Something went wrong")
failing_function() # Shows error message and re-raises
Testing
Run the test suite:
python -m pytest tests/ -v
Performance Notes
- Variable tracking uses
sys.settrace, which may slow down execution for large functions. - A warning is printed if execution takes more than 1 second.
- For production, set
debug=Falseto disable output.
Development
- Variable tracking uses
sys.settrace, which may slow down execution for large functions. - A warning is printed if execution takes more than 1 second.
- For production, set
debug=Falseto disable output.
Building the Package
To build the package for distribution:
pip install build
python -m build
This creates dist/debugger_decorator-<version>.tar.gz and dist/debugger_decorator-<version>-py3-none-any.whl.
Publishing to PyPI
-
Install Twine:
pip install twine
-
Upload to Test PyPI (recommended first):
twine upload --repository testpypi dist/*
-
Upload to Production PyPI:
twine upload dist/*
You'll need a PyPI account and API token. Set it up at pypi.org and use __token__ as username with your token as password.
Metadata
Release files for debugger-decorator 0.1.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| debugger_decorator-0.1.4.tar.gz | 7.5 kB | Without provenance | Details for debugger_decorator-0.1.4.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| debugger_decorator-0.1.4-py3-none-any.whl | Python 3 | none | any | Details for debugger_decorator-0.1.4-py3-none-any.whl |
Total release size: 15.4 kB
Release files / debugger_decorator-0.1.4.tar.gz
| Download URL | debugger_decorator-0.1.4.tar.gz |
|---|---|
| Size | 7.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b92fd4ace86f3d8517ca5a57d032d224a81eedcb1b9369878a0f2c707e1dc455
|
|
BLAKE2b-256 checksum How to use checksums |
7f3fc5a3c0225ccb72cd4d230570582343d1ba216b6ef992afedcbbb06bf793c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.0
|
Release files / debugger_decorator-0.1.4-py3-none-any.whl
| Download URL | debugger_decorator-0.1.4-py3-none-any.whl |
|---|---|
| Size | 7.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b3c5ffc14083f431482ed181de9392ee0406728105a4c735c9ab2fee7c2c4474
|
|
BLAKE2b-256 checksum How to use checksums |
7d216b07db6d0722f3259c94a26322fce284840eead4118740406dde89e2cc35
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.0
|
Security for debugger-decorator 0.1.4
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.