3

The code (taken from SO):

// create the logger and log writer
$writer = new Zend_Log_Writer_Firebug();
$logger = new Zend_Log($writer);

// get the wildfire channel
$channel = Zend_Wildfire_Channel_HttpHeaders::getInstance();

// create and set the HTTP response
$response = new Zend_Controller_Response_Http();
$channel->setResponse($response);

// create and set the HTTP request
$channel->setRequest(new Zend_Controller_Request_Http());

// record log messages
$logger->info('info message');
$logger->warn('warning message');
$logger->err('error message');

// insert the wildfire headers into the HTTP response
$channel->flush();

// send the HTTP response headers
$response->sendHeaders();

$this->_redirect('/login/success');

Apparently, all the messages won't appear if I use _redirect(), however, if I use something like

$this->getResponse()->setHeader('Refresh', '0; URL=/login/success');

it will work. So my question is:

What should I do to make sure the messages will appear in my Firebug Console (using _redirect())?

Update 1:

In the Net tab, I can see the messages are in the HEADER, but it's not appearing in my Firebug

Date    Wed, 08 Dec 2010 03:42:15 GMT 
Server  Apache/2.2.16 (Unix) DAV/2 PHP/5.3.3 
X-Powered-By    PHP/5.3.3 
Expires Thu, 19 Nov 1981 08:52:00 GMT 
Cache-Control   no-store, no-cache, must-revalidate, post-check=0, pre-check=0 
Pragma  no-cache 
X-Wf-Protocol-1 http://meta.wildfirehq.org/Protocol/JsonStream/0.2 
X-Wf-1-Structure-1  http://meta.firephp.org/Wildfire/Structure/FirePHP/FirebugConsole/0.1 
X-Wf-1-Plugin-1 http://meta.firephp.org/Wildfire/Plugin/ZendFramework/FirePHP/1.6.2 
X-Wf-1-1-1-1    156|[{"Type":"INFO","File":"\/home\/foo\/workspace\/php\/identiti\/application\/modules\/default\/controllers\/LoginController.php","Line":64},"info message"]| 
X-Wf-1-1-1-2    159|[{"Type":"WARN","File":"\/home\/foo\/workspace\/php\/identiti\/application\/modules\/default\/controllers\/LoginController.php","Line":65},"warning message"]| 
X-Wf-1-1-1-3    158|[{"Type":"ERROR","File":"\/home\/foo\/workspace\/php\/identiti\/application\/modules\/default\/controllers\/LoginController.php","Line":66},"error message"]| 
Location    /login/success 
Content-Length  0 
Keep-Alive  timeout=5, max=100 
Connection  Keep-Alive 
Content-Type    text/html

Update 2:

Apparently it's a bug, confirmed in FirePHP Official Forum. I'll wait untill there's a real fix before I answer this question.

Thanks for the detailed test case. This is a bug in FirePHP Companion.

Working on a fix. Will let you know when done (ETA Friday).

Thanks! Christoph

Community
  • 1
  • 1
Amree
  • 2,890
  • 3
  • 30
  • 51

2 Answers2

1

Does enabling the "Persist" option in the Firebug Console tab help?

Phil
  • 157,677
  • 23
  • 242
  • 245
  • Tried it before and it didn't work since there's nothing to persist – Amree Dec 08 '10 at 03:52
  • 1
    @foo By default, the console and net tabs clear out at the start of each request. As a redirect tells the client to make another request, you generally lose anything that might have been in the console. Enabling the persist option prevents the console from clearing. – Phil Dec 08 '10 at 03:54
  • I do understand that, but the problem is, even before the redirection process started, there's nothing in the Firebug console, but, it works when I use setHeader to redirect. It's still being redirected, but this time the messages show up in the console (with Persist option enabled) – Amree Dec 08 '10 at 03:59
1

This is the official answer from the author himself:

I have good and bad news. Logging during redirects works now for FirePHP 1.0 + FirePHP Companion. It will not work for the native Zend Framework implementation until early next year.

To get a working solution, please upgrade to FirePHP 1.0: http://upgrade.firephp.org/

Also see: http://www.christophdorn.com/Blog/2010/11/29/firephp-1-0-in-5-steps/

Instructions for logging during redirects:

http://reference.developercompanion.com/#/Tools/FirePHPCompanion/FAQ/#Redirect Messages

I would suggest using the FirePHP 1.0 library in addition to or instead of the ZF components. This will be much improved early next year.

Please let me know if you get this working.

Amree
  • 2,890
  • 3
  • 30
  • 51