Skip to main content

No project description provided

Project description

Python debugging library consisting of decorator trace functions to write code flow in diagram. Supports exporting to Pdf, Markdown, Drawio, Mermaid. It records function calls with arguments, return values, and elapsed time, then generates an HTML page with interactive buttons for exporting the trace. You can use it for your python projects by installing with pip install kodiag.

kodiag

Installation

pip install kodiag

Usage

kodiag exposes a single decorator, trace, imported directly from the package:

from kodiag import trace

trace must always be called with parentheses before decorating a function — @trace(), not bare @trace — since it takes an optional fileName argument that controls whether calls are logged to the console or recorded into an HTML diagram.

Console tracing — @trace()

Called with no arguments, trace prints each call to stdout as it happens, along with the return value and elapsed time. Nothing is written to disk.

from kodiag import trace

@trace()
def add(a, b):
    return a + b

add(1, 2)
• calling add((1, 2), {}) •
>>> add returned 3 and took 0.0000s <<<

Diagram tracing — @trace("fileName")

Pass a file name to record every call into an in-memory flow that is written out as an HTML diagram when the program exits (via atexit). The .html extension is added automatically if omitted.

from kodiag import trace

@trace("trace_output")
def fetch(user_id):
    ...

@trace("trace_output")
def process(data):
    ...

fetch(42)
process({"a": 1})
# trace_output.html is written on interpreter exit

Every function decorated with the same fileName appends to that file's flow in call order, so you can trace a whole call chain — across multiple functions — into one diagram.

Each recorded call captures:

  • function name
  • positional args and keyword args
  • the return value
  • elapsed time (seconds)

Arguments and return values are serialized for the diagram as follows: JSON-safe primitives (str, int, float, bool, None) pass through as-is, tuple/list/dict are serialized recursively, and anything else falls back to repr().

The generated HTML page renders each call as a card connected by arrows in call order, with an export bar at the bottom offering:

  • Copy Mermaid — copies a flowchart LR diagram to the clipboard
  • Download Draw.io — downloads a .drawio XML file of the flow
  • Copy Markdown — copies a Markdown table plus a flow summary
  • Print / Save PDF — opens the browser print dialog (the export bar is hidden in print output)

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

kodiag-0.1.5.tar.gz (5.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

kodiag-0.1.5-py3-none-any.whl (5.3 kB view details)

Uploaded Python 3

File details

Details for the file kodiag-0.1.5.tar.gz.

File metadata

  • Download URL: kodiag-0.1.5.tar.gz
  • Upload date:
  • Size: 5.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.9

File hashes

Hashes for kodiag-0.1.5.tar.gz
Algorithm Hash digest
SHA256 93d9a8db77b8c1f324324541ea93ef6d0d4be8bd657c28165e07e40097bb6584
MD5 12f75f7f57a35e2d44375bb2a4468137
BLAKE2b-256 adeddd70928abea80b0885b83157a25e477d42f1cd4fc67f2a0f0fa375a71224

See more details on using hashes here.

File details

Details for the file kodiag-0.1.5-py3-none-any.whl.

File metadata

  • Download URL: kodiag-0.1.5-py3-none-any.whl
  • Upload date:
  • Size: 5.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.9

File hashes

Hashes for kodiag-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 5f4ec7389ae7f9347bcdfbd7a96c515d6d5024fb57056dff443bc0010893b4fc
MD5 f99811b5e6654b98a76497ee376587b3
BLAKE2b-256 a062d172b8a17818ea565b962cc0e72a083ebdb01db320e7111174bdfac4bd57

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page