Zend Framework has functionality to send messages to the Firebug console (via Firefox’s FirePHP addon), but if you’re not using the ZF front controller, the API is a bit of a pain. Besides your instance of Zend_Log, you must keep track of a few additional objects just to manually flush the headers after all your logging calls. Since I knew the old FirePHP class didn’t need this follow-up step, I figured I could just flush the headers after each send.
The result is FireLog. On the FireLog instance, calls to methods like log(), info(), warn(), etc. are proxied to an internal Zend_Log instance, while the methods send(), group(), and groupEnd() are proxied to the static methods on Zend_Wildfire_Plugin_FirePhp. In both cases the headers are set immediately using some simple ZF subclassing.
$log = MrClay_FireLog::getInstance(); // Zend_Log methods $log->info('An informational message.'); $log->warn('A warning!'); // Zend_Wildfire_Plugin_FirePhp methods $log->group('My Group'); $log->send($someVariable, 'My variable'); $log->groupEnd();
This isn’t a substitute for the new FirePHP server-side framework, but if you just need some quick variable logging and you’ve got ZF on autoload, this will do the trick without having to install the FirePHP libraries. I’d be interested to know if this can log exceptions/errors.
Design note: I tried to make FireLog extend Zend_Log directly, but there was obviously some static cling. The class is a singleton just as a warning that there’s some global state (Wildfire’s HTTP “channel”) under the hood. Besides those issues, the Zend classes are nicely straightforward to extend.