Debugging¶
Developer tools for debugging Aksara applications.
Overview¶
Aksara provides powerful debugging tools for development:
- Debug Error Pages — Rich error pages with context
- AI Debug Tab — AI-powered fix suggestions
- Query Profiler — Database query analysis
- Request Inspector — Request/response details
Production Warning
Never enable debug mode in production. It exposes sensitive information.
Enabling Debug Mode¶
Via Constructor¶
Via Settings¶
# settings.py
DEBUG = True
# main.py
from aksara import Aksara
from myapp.settings import DEBUG
app = Aksara(debug=DEBUG)
Via Environment¶
Debug Features¶
Rich Error Pages¶
When an exception occurs in debug mode, you get a detailed error page:
- Exception type and message
- Full stack trace with code context
- Local variables at each frame
- Request details (headers, body, params)
- AI-powered fix suggestions
Request/Response Inspector¶
View complete request and response data:
Query Profiler¶
Track database queries:
from aksara.debug import query_profiler
@app.get("/api/posts")
async def list_posts(request):
with query_profiler() as profiler:
posts = await Post.objects.select_related("author").all()
print(f"Queries: {profiler.query_count}")
print(f"Time: {profiler.total_time}ms")
for query in profiler.queries:
print(f" {query.sql} ({query.time}ms)")
return posts
Section Contents¶
-
:material-alert-circle: Error Pages
Rich debugging error pages
-
:material-robot: AI Debug
AI-powered debugging suggestions
-
:material-database-search: Query Profiling
Database query analysis
Quick Debug Tips¶
Print Debugging¶
from aksara.debug import debug_print
@app.get("/api/data")
async def get_data(request):
data = await fetch_data()
debug_print(data) # Pretty prints with context
return data
Breakpoints¶
@app.get("/api/data")
async def get_data(request):
data = await fetch_data()
breakpoint() # Python debugger
return data
Query Logging¶
Related Documentation¶
- Error Pages — Debug error pages
- AI Debug — AI suggestions
- Query Profiling — Query analysis