Skip to main content

Debug utilities for Python with BitL Debug Bar integration

Project description

bitl-debug

Debug utilities for Python with BitL Debug Bar integration.

PyPI version License: MIT

Installation

pip install bitl-debug

# With Django support
pip install bitl-debug[django]

# With Flask support  
pip install bitl-debug[flask]

Quick Start

from bitl_debug import dump, dd

# Dump a value (continues execution)
dump({"user": "John", "age": 30})
dump(my_variable, "My Label")

# Dump and die (stops execution)
dd(suspicious_value)

Features

dump(value, label=None)

Send a value to BitL Debug Bar. Returns the value for chaining.

from bitl_debug import dump

user = {"name": "John", "email": "john@example.com"}
dump(user, "Current User")

# Chain dumps
result = dump(calculate_something())

dd(value, label=None)

Dump and die - sends a value and exits the process.

from bitl_debug import dd

# Debug and stop here
dd(suspicious_value, "Check this!")

# Code below never runs

log_error(error, label=None)

Log errors with full stack traces.

from bitl_debug import log_error

try:
    risky_operation()
except Exception as e:
    log_error(e)
    # Handle error...

log_query(sql, bindings=None, duration_ms=None)

Log database queries with timing.

from bitl_debug import log_query

log_query("SELECT * FROM users WHERE id = %s", [1], 12.5)

Django Integration

Add the middleware to your settings.py:

MIDDLEWARE = [
    'bitl_debug.middleware.DjangoMiddleware',
    # ... other middleware
]

All requests will be automatically logged to BitL Debug Bar.

Flask Integration

from flask import Flask
from bitl_debug.middleware import flask_middleware

app = Flask(__name__)
flask_middleware(app)

@app.route('/')
def hello():
    return 'Hello World!'

Configuration

from bitl_debug import configure

configure(
    host="127.0.0.1",  # BitL debug server host
    port=8765,         # BitL debug server port
    enabled=True,      # Enable/disable debugging
)

# Disable in production
import os
configure(enabled=os.environ.get("DEBUG", "false").lower() == "true")

Requirements

  • Python 3.10+
  • BitL app running with Debug Server enabled

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

bitl_debug-0.1.0.tar.gz (6.7 kB view details)

Uploaded Source

Built Distribution

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

bitl_debug-0.1.0-py3-none-any.whl (8.1 kB view details)

Uploaded Python 3

File details

Details for the file bitl_debug-0.1.0.tar.gz.

File metadata

  • Download URL: bitl_debug-0.1.0.tar.gz
  • Upload date:
  • Size: 6.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for bitl_debug-0.1.0.tar.gz
Algorithm Hash digest
SHA256 5d07a0197bb0407e5df0d1b6880475e6c98611c0e9527da7c4666b12eb20f70c
MD5 7eed46742f228a0a3d0716c73acfb0a2
BLAKE2b-256 977cdb48682d228a8be9355695300e07b921ff064fdcbdbed2edd47a06c7f910

See more details on using hashes here.

File details

Details for the file bitl_debug-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: bitl_debug-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 8.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for bitl_debug-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 281785289dc2891b0cae3c70e14bfa2db3e038c69d8881d8c15a3c8b9ee9b8f3
MD5 c04cb610561ac707edf0e79589bc6476
BLAKE2b-256 d22b65e54d7bd482eae7f4e16542912360d377c83fb3043799b74f5b41abeadf

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