Debug & Profiling
Lila includes an in-memory diagnostic engine (lila.core.debug). When
debugging is enabled, a pure ASGI middleware records the last 100 requests in RAM
(no disk I/O, no SQLite table) with their timing and status.
Enabling Debug Mode & Dashboard
The debugging features are only active when your application is in debug mode
(debug=True, or DEBUG=True in .env).
The Debug Dashboard (/debug) is mounted only when you also
pass debug_html=True during App initialization in
main.py:
from app.config import DEBUG
from lila.core.app import App
app = App(
routes=[router],
debug=DEBUG, # bool, not the string "False"
debug_html=DEBUG, # mounts GET/DELETE /debug and /debug/
)
What gets tracked?
For every non-static request, DebugStore appends one entry to the
in-memory history (collections.deque(maxlen=100)):
- Time: local
HH:MM:SSof the request. - Path & Method: endpoint accessed and HTTP method.
- IP Address: client IP (or
unknown). - Status Code: the HTTP response status.
- Duration: total wall time in milliseconds.
RAM/CPU figures come from DebugStore.get_system_metrics(). Lila uses
psutil when installed (pip install "lila-framework[metrics]")
and native OS fallbacks otherwise; values are never invented.
The Debug Dashboard
With debug=True, debug_html=True, Lila mounts:
GET /debug(and/debug/) — HTML dashboard.GET /debug/?fetch=true— JSON object withmetricsandhistory(true,Trueor1).DELETE /debug/— clears the in-memory history. Send the page CSRF token inX-CSRF-Token(or the_csrfcookie token).
The dashboard is not mounted when debug_html is false, and nothing is
recorded when debug is off.
Fetching Data Programmatically
Hit the same endpoint with the fetch query parameter:
curl http://localhost:8000/debug/?fetch=true
Reading the Store in Code
from lila.core.debug import DebugStore
history = DebugStore.get_all() # list[dict], newest first
metrics = DebugStore.get_system_metrics()
DebugStore.clear() # same as DELETE /debug/
Clearing Logs
Send a DELETE request to the dashboard URL (or call
DebugStore.clear()):
curl -X DELETE http://localhost:8000/debug/
/_lila/dev-reload
and /debug are only mounted when debug=True, so production keeps
zero overhead. Never enable debug_html on a public server: the dashboard
exposes request paths and client IPs.