Пример #1
0
 public function testLog4JNamespaceErrorLayout()
 {
     $event = LoggerTestHelper::getErrorEvent("testmessage");
     $layout = new LoggerLayoutXml();
     $layout->setLog4jNamespace(true);
     $layout->activateOptions();
     $actual = $layout->format($event);
     $thread = $event->getThreadName();
     $timestamp = number_format($event->getTimeStamp() * 1000, 0, '', '');
     $expected = "<log4j:event logger=\"test\" level=\"ERROR\" thread=\"{$thread}\" timestamp=\"{$timestamp}\">" . PHP_EOL . "<log4j:message><![CDATA[testmessage]]></log4j:message>" . PHP_EOL . "<log4j:locationInfo class=\"LoggerLoggingEvent\" file=\"NA\" line=\"NA\" " . "method=\"getLocationInformation\" />" . PHP_EOL . "</log4j:event>" . PHP_EOL;
     self::assertEquals($expected, $actual);
 }
 public function testSocketXml()
 {
     $appender = new LoggerAppenderSocket("myname ");
     $appender->setDry(true);
     $appender->setUseXml(true);
     $appender->setLocationInfo(true);
     $appender->activateOptions();
     $event = new LoggerLoggingEvent("LoggerAppenderSocketTest", new Logger("TEST"), LoggerLevel::getLevelError(), "testmessage");
     ob_start();
     $appender->append($event);
     $v = ob_get_contents();
     ob_end_clean();
     $layout = new LoggerLayoutXml();
     $layout->setLog4jNamespace(false);
     $layout->activateOptions();
     $a = $layout->format($event);
     $e = "DRY MODE OF SOCKET APPENDER: " . $a;
     self::assertEquals($e, $v);
 }