Пример #1
0
 public function tearDown()
 {
     Channel\HttpHeaders::destroyInstance();
     FirePhp::destroyInstance();
     date_default_timezone_set($this->_originaltimezone);
 }
Пример #2
0
 /**
  * Log a message to the Firebug Console.
  *
  * @param array $event The event data
  * @return void
  */
 protected function _write($event)
 {
     if (!$this->getEnabled()) {
         return;
     }
     if (array_key_exists($event['priority'], $this->_priorityStyles)) {
         $type = $this->_priorityStyles[$event['priority']];
     } else {
         $type = $this->_defaultPriorityStyle;
     }
     $message = $this->_formatter->format($event);
     $label = isset($event['firebugLabel']) ? $event['firebugLabel'] : null;
     FirePhp::getInstance()->send($message, $label, $type, array('traceOffset' => 4, 'fixZendLogOffsetIfApplicable' => true));
 }
Пример #3
0
    /**
     * @group ZF-4934
     */
    public function testAdvancedLogging()
    {
        FirePhp::getInstance()->setOption('maxTraceDepth',0);

        $message = 'This is a log message!';
        $label = 'Test Label';
        $table = array(
            'Summary line for the table',
            array(
		        array('Column 1', 'Column 2'),
		        array('Row 1 c 1',' Row 1 c 2'),
		        array('Row 2 c 1',' Row 2 c 2')
            )
        );

        $this->_logger->addPriority('TRACE', 8);
        $this->_logger->addPriority('TABLE', 9);
        $this->_writer->setPriorityStyle(8, 'TRACE');
        $this->_writer->setPriorityStyle(9, 'TABLE');

        $this->_logger->trace($message);
        $this->_logger->table($table);

        try {
            throw new \Exception('Test Exception');
        } catch (\Exception $e) {
            $this->_logger->err($e);
        }

        try {
            FirePhp::send($message, $label, 'UNKNOWN');
            $this->fail('Should not be able to log with undefined log style');
        } catch (\Zend\Wildfire\Plugin\Exception\UnexpectedValueException $e) {
            // success
        }

        $channel = Channel\HttpHeaders::getInstance();
        $protocol = $channel->getProtocol(FirePhp::PROTOCOL_URI);

        $messages = array(
            FirePhp::STRUCTURE_URI_FIREBUGCONSOLE => array(
                FirePhp::PLUGIN_URI => array(
                    1 => '[{"Type":"TABLE"},["Summary line for the table",[["Column 1","Column 2"],["Row 1 c 1"," Row 1 c 2"],["Row 2 c 1"," Row 2 c 2"]]]]'
        )));

        $qued_messages = $protocol->getMessages();

        unset($qued_messages[FirePhp::STRUCTURE_URI_FIREBUGCONSOLE][FirePhp::PLUGIN_URI][0]);
        unset($qued_messages[FirePhp::STRUCTURE_URI_FIREBUGCONSOLE][FirePhp::PLUGIN_URI][2]);

        $this->assertEquals(serialize($qued_messages),
                            serialize($messages));
    }
Пример #4
0
    /**
     * @group ZF-10526
     */
    public function testNonHTTPRequest()
    {
        $this->_request = new SimpleRequest();
        $this->_response = new Response();

        $channel = Channel\HttpHeaders::getInstance();
        $channel->setRequest($this->_request);
        $channel->setResponse($this->_response);

        // this should not fail with: PHP Fatal error:  Call to undefined method Zend_Controller_Request_Simple::getHeader()
        $this->assertFalse($channel->isReady());

        // this should not fail with: PHP Fatal error:  Call to undefined method Zend_Controller_Request_Simple::getHeader()
        $firephp = FirePhp::getInstance();
        $firephp->send('This is a log message!');
    }
Пример #5
0
    /**
     * @group ZF-10537
     */
    public function testFileLineOffsets()
    {
        $this->_setupWithoutFrontController();

        $firephp = FirePhp::getInstance();
        $channel = Channel\HttpHeaders::getInstance();
        $protocol = $channel->getProtocol(FirePhp::PROTOCOL_URI);
        $firephp->setOption('includeLineNumbers', true);
        $firephp->setOption('maxTraceDepth', 0);

        $lines = array();
        // NOTE: Do NOT separate the following pairs otherwise the line numbers will not match for the test

        // Message number: 1
        $lines[] = __LINE__+1;
        $firephp->send('Hello World');

        // Message number: 2
        $lines[] = __LINE__+1;
        $firephp->send('Hello World', null, 'TRACE');

        // Message number: 3
        $table = array('Summary line for the table',
                       array(
                           array('Column 1', 'Column 2'),
                           array('Row 1 c 1',' Row 1 c 2'),
                           array('Row 2 c 1',' Row 2 c 2')
                       )
                      );
        $lines[] = __LINE__+1;
        $firephp->send($table, null, 'TABLE');

        $messages = $protocol->getMessages();
        $messages = $messages[FirePhp::STRUCTURE_URI_FIREBUGCONSOLE][FirePhp::PLUGIN_URI];

        for( $i=0 ; $i<sizeof($messages) ; $i++ ) {
            if(!preg_match_all('/WildfireTest\.php","Line":' . $lines[$i] . '/', $messages[$i], $m)) {
                $this->fail("File and line does not match for message number: " . ($i+1));
            }

        }
    }
Пример #6
0
 /**
  * Enable or disable the profiler.  If $enable is false, the profiler
  * is disabled and will not log any queries sent to it.
  *
  * @param  boolean $enable
  * @return \Zend\Db\Profiler Provides a fluent interface
  */
 public function setEnabled($enable)
 {
     parent::setEnabled($enable);
     if ($this->getEnabled()) {
         if (!$this->_message) {
             $this->_message = new \Zend\Wildfire\Plugin\FirePhp\TableMessage($this->_label);
             $this->_message->setBuffered(true);
             $this->_message->setHeader(array('Time', 'Event', 'Parameters'));
             $this->_message->setDestroy(true);
             $this->_message->setOption('includeLineNumbers', false);
             \Zend\Wildfire\Plugin\FirePhp::getInstance()->send($this->_message);
         }
     } else {
         if ($this->_message) {
             $this->_message->setDestroy(true);
             $this->_message = null;
         }
     }
     return $this;
 }
Пример #7
0
 /**
  * @group ZF-10537
  */
 public function testFileLineOffsets()
 {
     $firephp = FirePhp::getInstance();
     $channel = Channel\HttpHeaders::getInstance();
     $protocol = $channel->getProtocol(FirePhp::PROTOCOL_URI);
     $firephp->setOption('includeLineNumbers', true);
     $firephp->setOption('maxTraceDepth', 0);
     $lines = array();
     // NOTE: Do NOT separate the following pairs otherwise the line numbers will not match for the test
     // Message number: 1
     $lines[] = __LINE__ + 1;
     $this->_logger->log('Hello World', Logger::INFO);
     // Message number: 2
     $this->_logger->addPriority('TRACE', 8);
     $this->_writer->setPriorityStyle(8, 'TRACE');
     $lines[] = __LINE__ + 1;
     $this->_logger->trace('Trace to here');
     // Message number: 3
     $this->_logger->addPriority('TABLE', 9);
     $this->_writer->setPriorityStyle(9, 'TABLE');
     $table = array('Summary line for the table', array(array('Column 1', 'Column 2'), array('Row 1 c 1', ' Row 1 c 2'), array('Row 2 c 1', ' Row 2 c 2')));
     $lines[] = __LINE__ + 1;
     $this->_logger->table($table);
     // Message number: 4
     $lines[] = __LINE__ + 1;
     $this->_logger->info('Hello World');
     $messages = $protocol->getMessages();
     $messages = $messages[FirePhp::STRUCTURE_URI_FIREBUGCONSOLE][FirePhp::PLUGIN_URI];
     for ($i = 0; $i < count($messages); $i++) {
         if (!preg_match_all('/FirebugTest\\.php","Line":' . $lines[$i] . '/', $messages[$i], $m)) {
             $this->fail("File and line does not match for message number: " . ($i + 1));
         }
     }
 }
Пример #8
0
 public function tearDown()
 {
     Channel\HttpHeaders::destroyInstance();
     FirePhp::destroyInstance();
 }
Пример #9
0
 /**
  * @group ZF-5540
  */
 public function testMaxObjectArrayDepth()
 {
     $this->_setupWithoutFrontController();
     $firephp = FirePhp::getInstance();
     $channel = Channel\HttpHeaders::getInstance();
     $protocol = $channel->getProtocol(FirePhp::PROTOCOL_URI);
     $firephp->setOption('maxObjectDepth', 2);
     $firephp->setOption('maxArrayDepth', 1);
     $obj = new TestObject3();
     $obj->testArray = array('val1', array('val2', array('Hello World')));
     $obj->child = clone $obj;
     $obj->child->child = clone $obj;
     $firephp->send($obj);
     $table = array();
     $table[] = array('Col1', 'Col2');
     $table[] = array($obj, $obj);
     $firephp->send($table, 'Label', FirePhp::TABLE);
     $messages = $protocol->getMessages();
     $message = $messages[FirePhp::STRUCTURE_URI_FIREBUGCONSOLE][FirePhp::PLUGIN_URI][0];
     $this->assertEquals($message, '[{"Type":"LOG"},{"__className":"ZendTest\\\\Wildfire\\\\TestObject3","public:name":"Name","public:value":"Value","undeclared:testArray":["val1","** Max Array Depth (1) **"],"undeclared:child":{"__className":"ZendTest\\\\Wildfire\\\\TestObject3","public:name":"Name","public:value":"Value","undeclared:testArray":["val1","** Max Array Depth (1) **"],"undeclared:child":"** Max Object Depth (2) **"}}]');
     $message = $messages[FirePhp::STRUCTURE_URI_FIREBUGCONSOLE][FirePhp::PLUGIN_URI][1];
     $this->assertEquals($message, '[{"Type":"TABLE","Label":"Label"},[["Col1","Col2"],[{"__className":"ZendTest\\\\Wildfire\\\\TestObject3","public:name":"Name","public:value":"Value","undeclared:testArray":["val1","** Max Array Depth (1) **"],"undeclared:child":{"__className":"ZendTest\\\\Wildfire\\\\TestObject3","public:name":"Name","public:value":"Value","undeclared:testArray":["val1","** Max Array Depth (1) **"],"undeclared:child":"** Max Object Depth (2) **"}},{"__className":"ZendTest\\\\Wildfire\\\\TestObject3","public:name":"Name","public:value":"Value","undeclared:testArray":["val1","** Max Array Depth (1) **"],"undeclared:child":{"__className":"ZendTest\\\\Wildfire\\\\TestObject3","public:name":"Name","public:value":"Value","undeclared:testArray":["val1","** Max Array Depth (1) **"],"undeclared:child":"** Max Object Depth (2) **"}}]]]');
 }