FireLogger for Python
a sexy logger console integrated into Firebug
Features
- Your logging messages are displayed right under your fingerprints in Firebug
- Support for rich-text logging (logged objects are sent as JSON object, you may drill down their structure)
- Support for exceptions and backtrace visualization
- Support for profiling graphs
- Ready as WSGI middleware and Django middleware
- Support for advanced features:
- open in Text Editor integration
- AppStats for GAE
- production paths remapping
- password protection
- logging proxy support
- and more ...
Compatibility
- Version 0.8 works with:
- alpha Firebug 1.6 + Firefox 3.6
- Firebug 1.4 and 1.5 + Firefox 3.5 or 3.6
- Version 0.7 works with:
- alpha Firebug 1.5 + Firefox 3.5
- Firebug 1.4.2 + Firefox 3.5
- Version 0.6 works with:
- alpha Firebug 1.5 + Firefox 3.5
- Firebug 1.4.2 + Firefox 3.5
- Version 0.5 works with:
- beta Firebug 1.4 + Firefox 3.0.x or Firefox 3.5
- does not work with Firebug 1.3 and older!
- Version 0.4 works with:
- Firebug 1.3 + Firefox 3.1
- Firebug 1.2.1 + Firefox 3.0.4.
- does not work with Firebug 1.4 alpha!
- Version 0.3 works with:
- Firebug 1.3 + Firefox 3.1
- Firebug 1.2.1 + Firefox 3.0.4.
- Version 0.2 is tested to work with alpha Firebug 1.3 and Firefox 3.1.
Installation
You definitely need Firebug 1.4 or higher. You also have to install Firefox Addon which is called FireLogger.
Easy Installation
Firefox Addon
Preferred way is to install this firefox extension via addons.mozilla.com.
Python Library
sudo easy_install firepython
Install from sources
Firefox Addon
If you want to install latest addon from sources, you need to build it. It should be simple, but make sure you have these tools on your paths:
- git
- zip
- ruby and rake
Build steps:
git clone git://github.com/darwin/firelogger.git
cd firelogger
rake
After that your XPI should be available in build/firelogger-X.Y.xpi.
You should be able to install XPI file into Firefox: File -> Open File ... and browse for firelogger-X.Y.xpi.
Remember, that you should be also using latest FirePython library on server-side (see next section).
Python Library
Just note, that it depends on simplejson (or some other json parsing library needed by jsonpickle).
Clone project from github in your project directory.
git clone git://github.com/darwin/firepython.git
Or if your web project uses git for versioning, you may want to be cool and use firepython as a submodule of your git repository.
git submodule add git://github.com/darwin/firepython.git relative/path/to/firepython
In case firepython directory is not on your import paths, you need to add relative/path/to folder into your sys.path.
Usage
Django
After installation, enable middleware by adding its path in MIDDLEWARE_CLASSES: firepython.middleware.FirePythonDjango.
WSGI compatible
After installation, enable middleware firepython.middleware.FirePythonWSGI.
Custom usage
Look for inspiration in middleware.py
Real world examples
- FirePython added to Bloog (blog engine for GAE)
- FirePython added to DryDrop (GAE hosting engine for GitHubbers && !Pythonists)
- FirePython added to Pyxer (Python web framework)
FAQ
logging.debug("hello world!") outputs nothing, what is wrong?
Default behavior of logging module is to output logs up from level INFO. Run "logging.getLogger().setLevel(logging.DEBUG)" to see all logs.
Is there something similar for PHP?
Check out FireLogger for PHP, you may also want to checkout alternative logging tool FirePHP
Is there something similar for Ruby?
Nope. I'd like to have one, but didn't find time to write server-side support. You are welcome to hack it!
How can I change the name of the default logger?
logging.getLogger().name = "my logger"
How can I open preferences?
Switch to Logger panel and look to Firebug's toolbar. There is a green bug icon. It is a menu button!
Clicking on source-file links in Logger panel does nothing. How can I open trace-back sources in TextMate?
Go to Firebug Menu -> Open With Editor -> Configure editors ... like this:
I was unable to download/install FireLogger extension from addons.mozilla.org. Can you package latest version for me?
Some people reported this problem too. You may try workaround.
How can I see Python profiling graph?
- enable this feature in FireLogger preferences
- setup a editor in External Editors in Firebug called "Graphviz" (the name is important!). It should be path to executable of a viewer for .dot graphs.
- reload page and you should see info log line containing profiling info, clicking on the line launches configured Graphviz viewer (a filename will be passed as the first parameter)
How can I use AppStats support?
If you are on production site, make sure you are logged in as project admin. Also don't forget to enable support in FireLogger's preferences.
When I start Firefox and page loads I don't see any log records, what is wrong?
First page content was probably loaded from cache. Refresh your page and you should be ok.
My page does multiple AJAX requests to the same URL, I see logs for the first response, but not for others. Am I missing something?
There is a bug in Firebug 1.4, it calls onResponse multiple times under some circumstances. That was very annoying, so I did a HACK and test for URL uniqueness in FireLogger. This will unfortunately filter out your multiple AJAX requests. Let's hope for fixes on Firebug side.
History
v0.8 (24.08.2010):
- [meatballhat] Daniel Buch did pythonification of the whole project, rewrote packaging scripts, added tests and demo site, big kudos!
- [darwin] added AppStats support for GAE (read more)
- [darwin] fixed bug when logging "something like this %s", param <= the last parameter was not printed into logger
- [darwin] better formatting string handling (closes #6)
- [darwin] marked as compatible with Firebug 1.6
v0.7 (24.08.2010):
- [darwin] fixed subtle bug when some log records with structs containing null values were not displayed
- [darwin] removed hack fingting duplicit requests
- [darwin] every batch of log records is prepended with ticket displaying request url
- [darwin] added toggle button to persist panel content between refreshes
- [darwin] rewriter correctly registers under Firebug namespace (fixed some bugs when detaching firebug panel)
- [darwin] usability: expand root item in watches in case there is only one root item
v0.6 (28.09.2009)
v0.5 (28.06.2009)
- [darwin] compatibility with Firebug 1.4
v0.4 (30.03.2009)
v0.3 (16.03.2009)
- [darwin] compatibility with Firebug 1.2
- [darwin] password protection for production site
- [darwin] path rewrite functionality
- [darwin] console supports rich formatting of python log messages
- [oxyum+piranha] thread-safety
- [darwin] improved API
- [darwin] Firefox Addon detached as a separate project FireLogger
- [darwin] option for hiding internal reprs of exported objects
v0.2 (24.11.2008)
v0.1 (15.11.2008)
- [darwin] public alpha release
- [darwin] initial server-side support for Python and Google App Engine
- [darwin] communication via response headers
- [darwin] logging module functionality (debug, info, warning, error, critical)
- [darwin] log record filtering by type
- [darwin] log record searching
- [darwin] opening files in TextMate (click to timestamp field)
Links
Articles
- Realtime logging to Firebug using FirePython by Antonin Hildebrand
- FirePython — no prints? by Alexander Solovyov
- Integrating FirePython with Pyxer by Dirk Holtwick
Contributors
- Alexander Solovyov - python server-side library, Django and WSGI middlewares.
- Ivan Fedorov - helped out with threading issues.
- Brett Slatkin - added profiling feature.
- Daniel Buch - pythonification of the whole project, rewrote packaging scripts, added tests and demo site, big kudos!
Also thanks to
- Joe Hewitt, John J. Barton, Jan Odvarko and others in Firebug working group - without these guys, the web wouldn't look like today.
- Christoph Dorn and FirePHP contributors - a lot of inspiration, good work mates!
- John Paulett for jsonpickle library - I was naively developing poor man's solution for inspecting objects in Python, but hopefully googled this gem early
- Jose Fonseca for gprof2dot library - deep Python profiling possible









