FullTracer is a Python library that provides a tracing mechanism to track the execution flow of Python code. It allows you to trace function calls and lines of code, generate formatted output with hyperlinks to IDEs, and customize the tracing behavior through configuration.
FullTracer can be installed using pip:
pip install fulltracer
The basic usage of FullTracer involves configuring the tracer with the desired settings, starting the tracing process, executing the code, and parsing the trace. Here's an example of how to use FullTracer:
from fulltracer import FullTracer
with FullTracer() as tracer:
# Code to be traced
my_func()
print(tracer)
from fulltracer import FullTracer
tracer = FullTracer(filename_pattern=__file__)
tracer.start()
# Code to be traced
my_func()
tracer.stop()
from fulltracer import FullTracer
tracer = FullTracer(filename_pattern=__file__)
@tracer
def my_func():
# Code to be traced
pass
my_func()
print(tracer)
Instead of
python my_script.py
use
fulltrace my_script.py
(Still working on getting fulltracer -m my_script
to work)
FullTracer provides a Config
class to configure the tracer's behavior. The available configuration options include:
anchor
: Anchor character used to pad lines.line_length
: Max expected length of a line in the source code.IDE
: IDE in which the code is being run.not_found
: String to be used when the source code file is not found.filename_pattern
: Regex pattern to match the filename.func_name_pattern
: Regex pattern to match the function name.line_pattern
: Regex pattern to match the line number.ignore_unfound_lines
: If True, lines not found in the source code are not included in the output.max_depth
: Maximum depth of the stack to be parsed.trace_lines
: If True, both function calls and lines are traced.parse
: Automatically parse the trace after stopping the tracer.depth_tab
: String to be used to indent the lines based on the depth of the stack.strip
: If True, leading and trailing whitespaces are stripped from the lines.link
: Template string to generate the hyperlinks.mode
: Template string to generate the output for a single line.consecutive_mode
: Template string to generate the output for consecutive lines.
For more detailed usage examples, refer to the samples directory in the FullTracer GitHub repository.
FullTracer is licensed under the Unlicense. See LICENSE for more information.