Python library for tracing function calls and performance
Project description
_____ __
_/ ____\_ __ ____ _____/ |_____________ ____ ____
\ __\ | \/ \_/ ___\ __\_ __ \__ \ _/ ___\/ __ \
| | | | / | \ \___| | | | \// __ \\ \__\ ___/
|__| |____/|___| /\___ >__| |__| (____ /\___ >___ >
\/ \/ \/ \/ \/
functrace is a Python library for detailed function call tracing. It provides logging and performance tracking to help monitor execution, measure timing, and debug effectively.
Getting Started
To begin using functrace
, you'll first need to install it. This can be easily done using pip
.
Simply run the following command to install the package:
pip install functrace
Quick Start
Get up and running with functrace
quickly by following this simple example.
Below is a basic usage scenario to help you integrate functrace
into your project and start tracing function calls.
from functrace import TraceResult, trace
def trace_callback(result: TraceResult) -> None:
function_call = result.function_call.format()
elapsed_time = result.elapsed_time.format()
returned_value = repr(result.returned_value)
exception = repr(result.exception)
parts = [function_call]
if result.is_started:
parts.extend(['Started'])
if result.is_completed:
parts.extend(['Completed', elapsed_time, returned_value])
if result.is_failed:
parts.extend(['Failed', elapsed_time, exception])
message = ' | '.join(parts)
print(message)
@trace(callback=trace_callback)
def func(a, b, c):
return a, b, c
if __name__ == '__main__':
func(1, 2, 3)
# func(a=1, b=2, c=3) | Started
# func(a=1, b=2, c=3) | Completed | 1 microsecond, 200 nanoseconds | (1, 2, 3)
Summary
You can find functrace
on PyPI for installation and package details. For comprehensive documentation and usage guides, visit Read the Docs. For source code and contributions, check out the GitHub repository.
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
File details
Details for the file functrace-0.0.3.tar.gz
.
File metadata
- Download URL: functrace-0.0.3.tar.gz
- Upload date:
- Size: 11.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9ce44141495767e988b9149214de68278154ff315998ac53479c401ff92fafc7 |
|
MD5 | 3dc0a61e5f3253b07eabc4707c3e5d4b |
|
BLAKE2b-256 | 9097ae2ab4d68317af6deec3426c6e371ca68a504d111bc7fefc625f5085a56f |
File details
Details for the file functrace-0.0.3-py3-none-any.whl
.
File metadata
- Download URL: functrace-0.0.3-py3-none-any.whl
- Upload date:
- Size: 7.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c90e97c8cc207480c7732714c99ebe5fbc868450bcf74211baf19a55fabba957 |
|
MD5 | 6065cf5839d9f9aa0b0f55dc449c1c19 |
|
BLAKE2b-256 | def6a6f86b9e825b2a77836e7491953791c706d45dd25ef100d7f3b003be3c08 |