Decorator functions to trace invocation of functions and class methods.
Project description
ftracer Package
ftracer - decorator functions to trace invocation of functions and class methods
DESCRIPTION
A Python module for tracing function and method invocations with detailed,
customizable logging. The ftracer module provides tools for decorating
individual functions, all functions in a module, and all methods in a class to
log their invocation, arguments, and return values. This is particularly
useful for debugging and understanding the flow of execution in your code.
ftracer allows developers to:
- Decorate individual functions with the
@tracedecorator to log their calls. - Decorate entire classes with the
@trace_methodsdecorator to trace all method calls within a class. - Automatically attach decorators to all functions or classes in a module
using
trace_all_functionsandtrace_all_classes. - Customize the tracing behavior, such as pretty-printing arguments and limiting list representations.
Key features:
- Customizable pretty-printer for function arguments and return values.
- Ability to apply tracing globally to all functions or classes in a module.
- Optional debug mode for additional trace logs.
EXAMPLE
Tracing Individual Functions
from ftracer import trace
@trace
def add(a, b):
return a + b
result = add(5, 3)
** add(a=5, b=3)
Tracing All Methods in a Class
from ftracer import trace_methods
@trace_methods
class Calculator:
def multiply(self, x, y):
return x * y
calc = Calculator()
calc.multiply(4, 7)
** multiply(self=<Calculator>, x=4, y=7)
Applying Traces Globally in a Module
from ftracer import trace_all_functions
trace_all_functions()
def greet(name):
return f"Hello, {name}!"
greet("Alice")
** greet(name='Alice')
INSTALLATION
pip3 install ftracer
AVAILABILITY
The latest version of ftracer module is available at
PyPI (https://pypi.org/project/ftracer/) .
SEE ALSO
AUTHOR
Hiroyuki Ohsaki <ohsaki[atmark]lsnl.jp>
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 ftracer-1.5.tar.gz.
File metadata
- Download URL: ftracer-1.5.tar.gz
- Upload date:
- Size: 15.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.11.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
62f723ba3c2930e5d5c4d633013c34903230323f0672c1e219bf45d8e7cc1238
|
|
| MD5 |
f96e7838bc64bd9642389ddcc32b4f3a
|
|
| BLAKE2b-256 |
273120bd31f51eb089c4886d9d8c6b813998af8669a83def70772b66ab8c92c9
|
File details
Details for the file ftracer-1.5-py3-none-any.whl.
File metadata
- Download URL: ftracer-1.5-py3-none-any.whl
- Upload date:
- Size: 16.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.11.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4db6aec072087ce034ac165ae6ab09d11cee3988f605a5490f6997d76e2de79a
|
|
| MD5 |
4bd89672475487c1cb9cfc516844832a
|
|
| BLAKE2b-256 |
ddafa6b3516cea6764c258435800a71f5912428a543744aa1f6b9decfba7b895
|