Skip to main content

Minimalist debug tool for Python with automatic cleaner

Project description

Siren

Minimalist debug tool for Python.

Siren is a lightweight alternative to print / pprint, designed to work
with any Python 3 version and any framework like Django, Flask, FastAPI, or pure Python scripts.

The main goal of Siren is simple:

✔ Debug fast
✔ Trace functions automatically
✔ Measure execution time
✔ Remove debug lines automatically
✔ Work everywhere
✔ Zero dependencies


Features

  • Works in Python 3+
  • No external dependencies
  • Uses print or pprint automatically for complex objects
  • Shows file and line number
  • Optional execution timer (timeit=True)
  • Trace decorator to log function calls and returns (@siren.trace)
  • Can remove all debug calls automatically
  • Safe cleaner using Python tokenize
  • Works in Django / Flask / FastAPI / scripts / CLI
  • Colored output with emoji

Installation

Install Siren via pip:

pip install siren-debug

Then, add siren to your framework’s configuration:

# Django example
INSTALLED_APPS = [
    # ...
    "siren",
]

Usage
x = 10
data = {"a": 1, "b": [1, 2, 3]}

siren(x)
siren(data)

Output:

[🧜‍ SIREN core.py:10] x = 10
[🧜‍ SIREN core.py:11] data = {'a': 1, 'b': [1, 2, 3]}

Siren automatically uses pprint for complex objects.

Multiple values
siren(x, data, user)
Timer
siren(x, timeit=True)

Outputs the value and the elapsed time:

[🧜‍ SIREN core.py:10] x = 10
[🧜‍ SIREN TIME] 0.000123s
Trace decorator
@siren.trace
def add(a, b):
    return a + b

add(2, 3)

Output:

[🧜‍ SIREN core.py:10] Calling add
[🧜‍ SIREN core.py:11] Returned from add -> 5
Cleaner (remove all siren calls)

This is the main feature.

Remove all lines that call siren(...):

siren-clean

Example:

Before:

siren(x)
print("hello")
siren(data)

After:

print("hello")

Cleaner is safe and uses Python tokenize.
It will not remove comments or strings.

Why Siren?

Using print or pprint for debugging is easy,
but removing them later is painful.

Siren solves this.

Use:

siren(value)

And later:

siren-clean

Done.

Goals

Minimal

Safe

Cross-version

No dependencies

Easy cleanup

Works offline

Function tracing & timing

License

MIT

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

siren_debug-0.2.0.tar.gz (3.3 MB view details)

Uploaded Source

Built Distribution

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

siren_debug-0.2.0-py3-none-any.whl (4.1 MB view details)

Uploaded Python 3

File details

Details for the file siren_debug-0.2.0.tar.gz.

File metadata

  • Download URL: siren_debug-0.2.0.tar.gz
  • Upload date:
  • Size: 3.3 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for siren_debug-0.2.0.tar.gz
Algorithm Hash digest
SHA256 177cbece054dd33d50e334134a17713e6344fdd098545b422fd1e61e812396d0
MD5 29b0e33aad012b6f6718db98dab4febf
BLAKE2b-256 098046db5966c17e258038c49183973ae6f8905b56b64deee1c48f32f8145a9b

See more details on using hashes here.

File details

Details for the file siren_debug-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: siren_debug-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 4.1 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for siren_debug-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 05855f645b79ffb60697d3f0966c6b4dc8cc98bc76e4dcdbd89e308a57a49623
MD5 5bb5cba69436fb6a7364f9395cff9a33
BLAKE2b-256 abcdd0603aab2fdaa31609d55cf54de193ec504a28d134f06c01a75a5da3e91e

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