开发者

FirePHP does not show extras when used with Zend_Log_Writer_Firebug

I've been developing with Zend Framework for ages (since 0.9) and this problem is nagging at my nerves ever since.

I want to output messages on the FireBug Console with the help of FirePHP and from a Zend Framework 1.11 Application. I've configured Firebug with the default application.ini-file:

resources.log.firebug.writerName = "Firebug"
resources.log.firebug.filterName = "Priority"
resources.log.firebug.filterParams.priority = 7

I can now see messages in FireBug, e.g. in the IndexController, by calling an invalid action or by explicitly throwing Exceptions like

throw new Exception("This is my error message", E_USER_ERROR);

This results in the default ErrorController handling the Exception and showing a stack trace and request parameters:

FirePHP does not show extras when used with Zend_Log_Writer_Firebug

The default ErrorController will also log all messages automatically to FireBug:

FirePHP does not show extras when used with Zend_Log_Writer_Firebug

However, as you can see, the extra-information like the stack trace or the request parameters are not shown, although FireBug is quite able to do so, as may be seen in this Screenshot of FireBug when visiting the mainpage:

FirePHP does not show extras when used with Zend_Log_Writer_Firebug

As the documentation states, Zend_Log_Writer_Firebug will ignor开发者_运维百科e all writerParams, with which a defaultPriorityStyle may be set to TRACE or something similar.

Now for my question: Is there any way to configure Zend Framework to also send over the extra data (as shown in the last picture) without having to use firePHPcore, but with the tools coming with Zend Framework itself?

Best Regards and Thanks in Advance!


I think you cannot achieve what you're saying with the default error controller generated from zf create project because the lines involved are these

// Log exception, if logger available
if ($log = $this->getLog()) {
    $log->log($this->view->message, $priority, $errors->exception);
    $log->log('Request Parameters', $priority, $errors->request->getParams());
}

i.e. the default error controller only log the message, the priority and the exception and the firebug writer format them in the way you shown.

To achieve what you're saying you should hack the Zend_Log_Writer_Firebug class to display the stacktrace using the firebug console or alternatively you can play with a custom formatter class added to your logger.

I did something similar by creating a mail logger which displays formatted exception stacktrace in a mail message and use when in production to obtain a formatted log of the exception sent by email. You can find it here on Github and here you can find its usage.

Moreover you can see an example on how to use the firebug console using the ZF classes in the Zend_Db_Profiler_Firebug class.

So to answer your question, no you can't do that without writing some custom class and it as writer or formatter to the log object nor you can do that by just using the application.ini file.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜