/**
  * Initializes this logger.
  *
  * Available options:
  *
  * - web_debug_class: The web debug class (sfWebDebug by default).
  *
  * @param  sfEventDispatcher $dispatcher  A sfEventDispatcher instance
  * @param  array             $options     An array of options.
  *
  * @return Boolean           true, if initialization completes successfully, otherwise false.
  *
  * @see sfVarLogger
  */
 public function initialize(sfEventDispatcher $dispatcher, $options = array())
 {
     $this->context = sfContext::getInstance();
     $this->dispatcher = $dispatcher;
     $this->webDebugClass = isset($options['web_debug_class']) ? $options['web_debug_class'] : 'sfWebDebug';
     if (sfConfig::get('sf_web_debug')) {
         $dispatcher->connect('response.filter_content', array($this, 'filterResponseContent'));
     }
     return parent::initialize($dispatcher, $options);
 }
Example #2
0
 /**
  * Initializes this logger.
  *
  * Available options:
  *
  *  * web_debug_class: The web debug class (sfWebDebug by default)
  *
  * @param  sfEventDispatcher $dispatcher  A sfEventDispatcher instance
  * @param  array             $options     An array of options.
  *
  * @return Boolean           true, if initialization completes successfully, otherwise false.
  *
  * @see sfVarLogger
  */
 public function initialize(sfEventDispatcher $dispatcher, $options = array())
 {
     $this->context = sfContext::getInstance();
     $this->webDebugClass = isset($options['web_debug_class']) ? $options['web_debug_class'] : 'sfWebDebug';
     if (sfConfig::get('sf_web_debug')) {
         $dispatcher->connect('context.load_factories', array($this, 'listenForLoadFactories'));
         $dispatcher->connect('response.filter_content', array($this, 'filterResponseContent'));
     }
     $this->registerErrorHandler();
     return parent::initialize($dispatcher, $options);
 }
Example #3
0
 public function initialize(sfEventDispatcher $dispatcher, $options = array())
 {
     $this->sfFire = sfFirePHP::getInstance(true);
     if (isset($options['processor'])) {
         sfFirePHP::setProcessor($options['processor'] . '?' . time());
     }
     if (isset($options['renderer'])) {
         sfFirePHP::setRenderer($options['renderer'] . '?' . time());
     }
     $dispatcher->connect('response.filter_content', array($this, 'filterResponseContent'));
     $this->dispatcher = $dispatcher;
     return parent::initialize($dispatcher, $options);
 }
    }
}
class sfWebDebugPanelPropelTestDifferentGlue extends sfWebDebugPanelPropel
{
    protected function getPropelConfiguration()
    {
        $config = new PropelConfiguration(array());
        $config->setParameter('debugpdo.logging.outerglue', 'xx');
        $config->setParameter('debugpdo.logging.innerglue', '/ ');
        $config->setParameter('debugpdo.logging.details.slow.enabled', true);
        $config->setParameter('debugpdo.logging.details.slow.threshold', 5);
        return $config;
    }
}
// ->getPanelContent()
$t->diag('->getPanelContent()');
$dispatcher = new sfEventDispatcher();
$logger = new sfVarLogger($dispatcher);
$logger->log('{sfPropelLogger} SELECT * FROM foo WHERE bar<1');
$logger->log('{sfPropelLogger} time: 3.42 sec | mem: 2.8 MB | SELECT * FROM foo WHERE aText like \' | foo\'');
$panel = new sfWebDebugPanelPropelTest(new sfWebDebug($dispatcher, $logger));
$content = $panel->getPanelContent();
$t->like($content, '/bar&lt;1/', '->getPanelContent() returns escaped queries');
$t->like($content, '/aText like &#039; | foo&#039;/', '->getPanelContent() works with glue string in SQL');
$t->like($content, '/sfWebDebugWarning/', '->getPanelContent() contains a slow query warning');
$logger = new sfVarLogger($dispatcher);
$logger->log('{sfPropelLogger} time/ 3.42 secxxmem/ 2.8 MBxxSELECT * FROM foo WHERE bar == 42');
$panel = new sfWebDebugPanelPropelTestDifferentGlue(new sfWebDebug($dispatcher, $logger));
$content = $panel->getPanelContent();
$t->like($content, '/time\\/ 3.42 sec, mem\\/ 2.8 MB/', '->getPanelContent() works with strange glue strings');
$t->unlike($content, '/sfWebDebugWarning/', '->getPanelContent() should not contain a slow warning');
Example #5
0
<?php

/*
 * This file is part of the symfony package.
 * (c) Fabien Potencier <*****@*****.**>
 * 
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */
require_once dirname(__FILE__) . '/../../bootstrap/unit.php';
$t = new lime_test(9);
$dispatcher = new sfEventDispatcher();
$buffer = fopen('php://memory', 'rw');
$logger = new sfVarLogger($dispatcher);
$logger->log('foo');
$logger->log('{sfFoo} bar', sfLogger::ERR);
$logs = $logger->getLogs();
$t->is(count($logs), 2, 'sfVarLogger logs all messages into its instance');
$t->is($logs[0]['message'], 'foo', 'sfVarLogger returns an array with the message');
$t->is($logs[0]['priority'], 6, 'sfVarLogger returns an array with the priority');
$t->is($logs[0]['priority_name'], 'info', 'sfVarLogger returns an array with the priority name');
$t->is($logs[0]['type'], 'sfOther', 'sfVarLogger returns an array with the type');
$t->is($logs[1]['message'], 'bar', 'sfVarLogger returns an array with the message');
$t->is($logs[1]['priority'], 3, 'sfVarLogger returns an array with the priority');
$t->is($logs[1]['priority_name'], 'err', 'sfVarLogger returns an array with the priority name');
$t->is($logs[1]['type'], 'sfFoo', 'sfVarLogger returns an array with the type');
<?php

/*
 * This file is part of the symfony package.
 * (c) Fabien Potencier <*****@*****.**>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */
require_once dirname(__FILE__) . '/../../bootstrap/unit.php';
$t = new lime_test(1);
class sfWebDebugPanelPropelTest extends sfWebDebugPanelPropel
{
    protected function getSlowQueryThreshold()
    {
        return 0.01;
    }
}
// ->getPanelContent()
$t->diag('->getPanelContent()');
$dispatcher = new sfEventDispatcher();
$logger = new sfVarLogger($dispatcher);
$logger->log('{sfPropelLogger} SELECT * FROM foo WHERE bar<1');
$panel = new sfWebDebugPanelPropelTest(new sfWebDebug($dispatcher, $logger));
$t->ok(false !== strpos($panel->getPanelContent(), 'bar&lt;1'), '->getPanelContent() returns escaped queries');