开发者

Zend_Log_Writer_Firebug() not working

开发者 https://www.devze.com 2023-02-17 15:32 出处:网络
I have Firefox 3.6.15, Firebug and FirePHP addons installed, console enabled. I am using Zend 1.11. The following code doesn\'t show anything in the firebug console.

I have Firefox 3.6.15, Firebug and FirePHP addons installed, console enabled. I am using Zend 1.11. The following code doesn't show anything in the firebug console.

<?php
    require_once('Zend/Log.php');
    require_once('Zend/Log/Writer/Firebug.php');

    $writer = new Zend_Log_Writer_Firebug();
    $logger = new Zend_Log($writer);

    $logger->info('info message');
    $logger->warn('warning message');
    $logger->err('error message');
?>

I tried with the FirePHP core library and this works -

<?php
     require_once('FirePHPCore/FirePHP.class.php');
     ob_start();

     $firephp = FirePHP::getInstance(true); 
     $var = array('i'=>10, 'j'=>20);

     $firephp->log($var, 'Iterators');
?>开发者_如何学运维;

Would like to get the Zend thing working. Any idea?


Try with place

$request = new Zend_Controller_Request_Http();
$response = new Zend_Controller_Response_Http();
$channel = Zend_Wildfire_Channel_HttpHeaders::getInstance();
$channel->setRequest($request);
$channel->setResponse($response);
//buffering
ob_start();

before logger message.

also after

// flushing
$channel->flush();
$response->sendHeaders();


Well, actually the main difference between the 2 fragments of code is that in the FirePHP code you're turning on output buffering (with the obstart(); call) and in the Zend Framework code fragment you don't. The easiest way to get it to work with Zend is probably to set the output_buffering flag in php.ini to On (you can do that in your virtual host definition or htaccess when using apache if you don't want to set it globally).

I just use this in my Bootstrap :

protected function _initLogger()
{
    $writer = new Zend_Log_Writer_Firebug();
    $logger = new Zend_Log($writer);

    Zend_Registry::set('logger', $logger);
}

And then use Zend_Registry::get('logger')->log(...); and it works with output_buffering set to on (FF 3.6.15, Firebug 1.6.2, FirePHP 0.5.0).

0

精彩评论

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