public function testLoggerNDC()
 {
     LoggerNDC::clear();
     $layout = new LoggerLayoutPattern('{ndc}');
     $message = $layout->formatMessage(new Logger("root"), Logger::INFO, '');
     $this->assertEquals('' . PHP_EOL, $message);
     LoggerNDC::push("ndc");
     $message = $layout->formatMessage(new Logger("root"), Logger::INFO, '');
     $this->assertEquals('ndc' . PHP_EOL, $message);
 }
Exemplo n.º 2
0
 public function testNDC()
 {
     LoggerNDC::push('foo');
     LoggerNDC::push('bar');
     $event = LoggerTestHelper::getErrorEvent("testmessage");
     $layout = new LoggerLayoutXml();
     $layout->activateOptions();
     $actual = $layout->format($event);
     $thread = $event->getThreadName();
     $timestamp = number_format($event->getTimeStamp() * 1000, 0, '', '');
     $expected = "<log4php:event logger=\"test\" level=\"ERROR\" thread=\"{$thread}\" timestamp=\"{$timestamp}\">" . PHP_EOL . "<log4php:message><![CDATA[testmessage]]></log4php:message>" . PHP_EOL . "<log4php:NDC><![CDATA[<![CDATA[foo bar]]>]]></log4php:NDC>" . PHP_EOL . "<log4php:locationInfo class=\"LoggerLoggingEvent\" file=\"NA\" line=\"NA\" " . "method=\"getLocationInformation\" />" . PHP_EOL . "</log4php:event>" . PHP_EOL;
     self::assertEquals($expected, $actual);
     LoggerNDC::clear();
 }
Exemplo n.º 3
0
 public function testMaxDepth()
 {
     // Clear stack; add some testing data
     LoggerNDC::clear();
     LoggerNDC::push('1');
     LoggerNDC::push('2');
     LoggerNDC::push('3');
     LoggerNDC::push('4');
     LoggerNDC::push('5');
     LoggerNDC::push('6');
     self::assertSame('1 2 3 4 5 6', LoggerNDC::get());
     // Edge case, should not change stack
     LoggerNDC::setMaxDepth(6);
     self::assertSame('1 2 3 4 5 6', LoggerNDC::get());
     self::assertSame(6, LoggerNDC::getDepth());
     LoggerNDC::setMaxDepth(3);
     self::assertSame('1 2 3', LoggerNDC::get());
     self::assertSame(3, LoggerNDC::getDepth());
     LoggerNDC::setMaxDepth(0);
     self::assertSame('', LoggerNDC::get());
     self::assertSame(0, LoggerNDC::getDepth());
 }
Exemplo n.º 4
0
 /**
  * Remove the diagnostic context for this thread.
  */
 public static function remove()
 {
     LoggerNDC::clear();
 }
Exemplo n.º 5
0
 /**
  * Remove the diagnostic context for this thread.
  * @static
  */
 function remove()
 {
     LoggerLog::debug("LoggerNDC::remove()");
     LoggerNDC::clear();
 }
 public function setUp()
 {
     LoggerNDC::clear();
     LoggerMDC::clear();
     parent::setUp();
 }