trace-to-log
A simple library to add some logging of selected functions via a trace
decorator.
By default, tracing is only enabled if TRACE_ME environment variable is set
Example:
from trace_to_log import trace
@trace('*')
def adder(x:int, y:int) -> int:
return x + y
Note, the '*' argument means all arguments should be logged. Otherwise, no arguments are logged.
Now, calling adder will result in the following log entries at DEBUG level:
Going to call adder with args:
x :: 1
y :: 2
adder took 9.5367431640625e-07 seconds
Finished adder, returned:3
being picky
If you don't want to log every argument, maybe because the string representation of one of the objects is verbose, you can explicitly select which arguments to log:
from trace_to_log import trace
@trace('x')
def adder(x:int, y:int) -> int:
return x + y
This will result in:
Going to call adder with args:
x :: 1
adder took 9.5367431640625e-07 seconds
Finished adder, returned:3
custom argument conversions
Make log interpretation easier with a custom representation:
from trace_to_log import trace
to_hex = lambda x: format(x, '#010x')
@trace('value', address=to_hex)
def write_32(address:int, value:int):
pass
This will result in:
Going to call write_32 with args:
address :: 0x20000000
value :: 12"
write_32 took 1.6689300537109375e-06 seconds
Finished write_32, returned:None
Unconditionally enabling tracing
from trace_to_log import make_trace
trace = make_trace(
trace_enable=lambda: True,
)
@trace('*')
def adder(x:int, y:int) -> int:
return x + y
Metadata
Release files for trace-to-log 0.2.0
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 |
|---|---|---|---|---|
| trace_to_log-0.2.0.tar.gz | 2.8 kB | Without provenance | Details for trace_to_log-0.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| trace_to_log-0.2.0-py3-none-any.whl | Python 3 | none | any | Details for trace_to_log-0.2.0-py3-none-any.whl |
Total release size: 6.5 kB
Release files / trace_to_log-0.2.0.tar.gz
| Download URL | trace_to_log-0.2.0.tar.gz |
|---|---|
| Size | 2.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
04755caf056c430a04dd62a4283a372077548524b487153a7d2c357984e23a48
|
|
BLAKE2b-256 checksum How to use checksums |
e10fab009431d3fa4f882eb310a2f7a03c4ee1b4a4ad942e72e5c86dcb9cc32d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.9.8
|
Release files / trace_to_log-0.2.0-py3-none-any.whl
| Download URL | trace_to_log-0.2.0-py3-none-any.whl |
|---|---|
| Size | 3.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
4595a21022df768cc0743be97885accb1dd3978cee07f050a621976e8c3a111d
|
|
BLAKE2b-256 checksum How to use checksums |
fdcdf62c830dd07cb244497b60e4aafde65437a60ce05adfe37e87b469be3bef
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.9.8
|
Security for trace-to-log 0.2.0
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.