Skip to main content

Produce function trace for Python code in Xdebug format

Project description

This module prints function trace to stdout from the moment it is called:

import xtrace
xtrace.start()
...
xtrace.stop()

It is also possible to call xtrace as module from the command line:

python -m xtrace <script.py> [param] ...

or use as a standalone script:

python xtrace.py <script.py> [param] ...

The output format is inspired by Xdebug function traces and will likely to merge with it http://xdebug.org/docs/execution_trace to be compatible with PHP inspection tools. But I didn’t have enough time to polish it, so feel free to send a patch if you know how to bring them closer.

This code is released into public domain. Enjoy!

History

  • 0.4 - added beep function which beeps in DEBUG mode when excited

  • 0.3 - fix AttributeError when running from console (issue #2)

  • 0.2 - added version info, support running from command line, moved main functions into a class to isolate used variables in local namespace

  • 0.1 - initial release

Credits

Amaury Forgeot d’Arc, for valuable insight into Python internals

Debugging

To see various internal events that xtrace produces on top of standard data provided by Python, enable DEBUG option:

import xtrace
xtrace.DEBUG = True

This will call beep functiton for every interesting event. Feel free to override it (monkeypatch) with your own to filter messages, forward, etc.

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

xtrace-0.4.tar.gz (3.2 kB view details)

Uploaded Source

File details

Details for the file xtrace-0.4.tar.gz.

File metadata

  • Download URL: xtrace-0.4.tar.gz
  • Upload date:
  • Size: 3.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for xtrace-0.4.tar.gz
Algorithm Hash digest
SHA256 fae70222e8d57fa3c4e98b1426f587503917ccbef844854fa93628c04e4aa8dc
MD5 7337adb1648954035f84d1e6e7339ae6
BLAKE2b-256 455da45a0b9844152453698a7e13f2bea4181e4d8d9b5f08d94110bd04a2082c

See more details on using hashes here.

Supported by

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