While I’m developing some web application I almost never use any debuggers or
supporting tools: in 90% of cases usual
print variable is enough for
understanding a trouble. Of course, there are some very complicated cases, when
import pdb; pdb.set_trace().
But I was pointed at very cool thing yesterday - FirePython. This thing consists of two parts - small library on python and plugin for Firebug. This tandem is engaged with very useful business - it displays all python logged activity1 in Firebug tab.
This tool is really helpful - now I need only two applications for development:
an editor and a browser. Good news is that I don’t need to look for print output
runserver output. Regarding usual usage of
logging there are some
benefits too - at least you don’t need to follow files and their paths (for
creation of which you may not have rights), moreover immediately you have nice
viewer for logs with ability to filter them.
I’ve contributed today to development of FirePython by development of two
middlewares - one for Django and one for WSGI applications, so now its usage is
just a question of few movements. ;) In short: you need to install plugin
itself, which depends on Firebug 1.3 (it’s still in beta stage, but I’m
using Firefox 3.1, so this is not scary for me :P). After that do
firepython. Another option: clone project from github and put folder
python folder in
sys.path or your project directory.
After that you just need to enable middleware by adding its path in
firepython.django.FirePythonDjango. WSGI middleware has
another path (how strange! :D):
firepython.wsgi.FirePythonWSGI, which you
should use as any other WSGI middleware.
Usage of whole system in code looks like:
import logging logging.debug('what you want to debug today?')
Naturally you can use any level instead of debug - you can filter them in FirePython interface.