| Issue 120: | Add printf-style logging API | |
| 1 person starred this issue and may be notified of changes. | Back to list |
Sign in to add a comment
|
I propose to extend FirePHP's logging API with formatted string logging much like Firebug's own `console.log` [1]. This would add variable argument length logging methods to FirePHP, like `FirePHP::logf($format, $arg1, ... $argN)`, `FirePHP::warnf($format, $arg1, ... $argN)` and so on. The `$format` string would be interpolated with the %s, %d, %i and %f format specifiers like `sprintf()` [2], and the %o specifier would expand to a link to FirePHP variable inspector. [1] <http://getfirebug.com/console.html> [2] <http://no.php.net/manual/en/function.sprintf.php> [*] firephp-dev thread: <http://groups.google.com/group/firephp-dev/browse_thread/thread/2bc69717da7643d0> |
||||||||||
,
Jul 16, 2009
(No comment was entered for this change.)
Status: Accepted
Labels: Milestone-FirePHPCore-0.3.2 |
|||||||||||
,
Jul 21, 2009
Attached is a patch (formatted_logging_simple.diff) against /branches/Library-FirePHPCore-0.3 which adds logf(), warnf(), infof() and errorf() to the FirePHP class. These methods simply send the format string and any format arguments in the meta section as `PrintFParameters`. For testing, I also implemented a custom request processor (RequestProcessor.js) which checks for format parameters and expands the format string using the simple semantics of Firebug's console.log(). The resulting array is then logged using Firebug. It wouldn't be too difficult to implement more advanced format expansion such as padding, alignment and additional type specifiers, but I've tried to keep it simple for now. (Who uses that stuff anyway?) I did write a patch which uses PHP's own sprintf() for the expansion, but it didn't turn out very pretty ;) What remains is to customize logToFirebug() to handle formatted log messages. I could quite figure out how to do this unfortunately as I'm not very familiar with Firebug's internal API. (Building the extension itself was not too easy either :) (See `test.php` for a simple testcase) |
|||||||||||
,
Jul 21, 2009
Very nice! I can make the necessary changes to the extension. I'll make sure this get's included with the next update. Thanks for all your effort! |
|||||||||||
|
|
|||||||||||