Python
The fanar PyPI package works in any Python 3.8+ project — Django, Flask, FastAPI, scripts, or notebooks. Payloads are sent in a background thread so they never block your code.
Installation
pip install fanar Basic usage
import fanar
# Strings and primitives → log
fanar.log('request received')
fanar.log(42)
# Dicts, lists, objects → collapsible JSON tree
fanar.dump({'user': user, 'session': session})
fanar.dump(response.json())
# Exceptions → stack trace with clickable frames
try:
process_order(order)
except Exception as e:
fanar.exception(e) Labels and project tags
Pass label and project keyword arguments to any call. Labels appear in the header row and are searchable.
fanar.log('cache miss', label='redis')
fanar.dump(payload, label='incoming webhook', project='billing') SQL queries
Use fanar.query() to send SQL with bound values and execution time. The app shows syntax highlighting and marks slow queries.
import time
import fanar
start = time.monotonic()
rows = cursor.execute('SELECT * FROM orders WHERE user_id = %s', [user_id])
fanar.query(
'SELECT * FROM orders WHERE user_id = %s',
bindings=[user_id],
duration=int((time.monotonic() - start) * 1000),
) Named timers
Measure any block of code. Call .stop() to send the elapsed time.
t = fanar.time('render-pdf')
render_pdf(report)
t.stop()
# As a context manager
with fanar.timer('send-emails'):
send_batch(recipients) Django integration
Add FanarMiddleware to capture every request automatically, including queries and exceptions.
# settings.py
MIDDLEWARE = [
'fanar.django.FanarMiddleware',
# ... rest of your middleware
]
FANAR = {
'ENABLED': DEBUG,
'HOST': '127.0.0.1',
'PORT': 23517,
} Configuration
Configure once at startup — before any fanar.* calls.
import fanar
fanar.configure(
host='localhost', # default
port=23517, # default
enabled=True, # set to False to disable without removing calls
) | Option | Default | Description |
|---|---|---|
| host | localhost | Hostname or IP of the machine running Fanar |
| port | 23517 | Port the Fanar desktop app is listening on |
| enabled | True | Set to False to disable without removing calls |