本文整理汇总了PHP中LoggerLevel::getLevelError方法的典型用法代码示例。如果您正苦于以下问题:PHP LoggerLevel::getLevelError方法的具体用法?PHP LoggerLevel::getLevelError怎么用?PHP LoggerLevel::getLevelError使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LoggerLevel
的用法示例。
在下文中一共展示了LoggerLevel::getLevelError方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getLoggerLevel
public static function getLoggerLevel($level)
{
switch (strtolower($level)) {
case 'trace':
$level = LoggerLevel::getLevelTrace();
break;
case 'debug':
$level = LoggerLevel::getLevelDebug();
break;
case 'warn':
$level = LoggerLevel::getLevelWarn();
break;
case 'error':
$level = LoggerLevel::getLevelError();
break;
case 'fatal':
$level = LoggerLevel::getLevelFatal();
break;
case 'info':
default:
$level = LoggerLevel::getLevelInfo();
break;
}
return $level;
}
示例2: testSimpleLogging
public function testSimpleLogging()
{
if (!extension_loaded('pdo_sqlite')) {
self::markTestSkipped("Please install 'pdo_sqlite' in order to run this test");
}
$event = new LoggerLoggingEvent("LoggerAppenderPDOTest", new Logger("TEST"), LoggerLevel::getLevelError(), "testmessage");
$dbname = '../../../target/pdotest.sqlite';
$dsn = 'sqlite:' . $dbname;
$database = new PDO($dsn);
$database = null;
$appender = new LoggerAppenderPDO("myname");
$appender->setDSN($dsn);
$appender->setCreateTable(true);
$appender->activateOptions();
$appender->append($event);
$db = $appender->getDatabaseHandle();
$q = "select * from log4php_log";
$error = "";
if ($result = $db->query($q)) {
while ($row = $result->fetch()) {
self::assertEquals($row['1'], 'TEST');
self::assertEquals($row['2'], 'ERROR');
self::assertEquals($row['3'], 'testmessage');
}
} else {
// todo propagate exception to phpunit
self::assertTrue(false);
}
$appender->close();
}
示例3: testSimpleLayout
public function testSimpleLayout()
{
$event = new LoggerLoggingEvent("LoggerLayoutSimpleTest", new Logger("TEST"), LoggerLevel::getLevelError(), "testmessage");
$layout = new LoggerLayoutSimple();
$v = $layout->format($event);
$e = "ERROR - testmessage\n";
self::assertEquals($v, $e);
}
示例4: testErrorLayout
public function testErrorLayout()
{
$event = new LoggerLoggingEvent("LoggerLayoutXml", new Logger("TEST"), LoggerLevel::getLevelError(), "testmessage");
$layout = new LoggerLayoutXml();
$v = $layout->format($event);
$e = "<log4php:event logger=\"TEST\" level=\"ERROR\" thread=\"" . $event->getThreadName() . "\" timestamp=\"" . number_format((double) ($event->getTimeStamp() * 1000), 0, '', '') . "\">" . PHP_EOL . "<log4php:message><![CDATA[testmessage]]></log4php:message>" . PHP_EOL . "<log4php:locationInfo class=\"LoggerLoggingEvent\" file=\"NA\" line=\"NA\" " . "method=\"getLocationInformation\" />" . PHP_EOL . "</log4php:event>\n" . PHP_EOL;
self::assertEquals($v, $e);
}
示例5: testErrorLayout
public function testErrorLayout()
{
$event = new LoggerLoggingEvent("LoggerLayoutXml", new Logger("TEST"), LoggerLevel::getLevelError(), "testmessage");
$e = 'ERROR TEST : testmessage in NA at NA' . PHP_EOL;
$patternParser = new LoggerPatternParser("%-5p %c %X{username}: %m in %F at %L%n");
$c = $patternParser->parse();
$c->format($e, $event);
}
示例6: testErrorLayout
public function testErrorLayout()
{
$event = new LoggerLoggingEvent("LoggerLayoutHtmlTest", new Logger("TEST"), LoggerLevel::getLevelError(), "testmessage");
$layout = new LoggerLayoutHtml();
$v = $layout->format($event);
$e = PHP_EOL . "<tr>" . PHP_EOL . "<td>" . round(1000 * $event->getRelativeTime()) . "</td>" . PHP_EOL . "<td title=\"" . $event->getThreadName() . " thread\">" . $event->getThreadName() . "</td>" . PHP_EOL . "<td title=\"Level\">ERROR</td>" . PHP_EOL . "<td title=\"TEST category\">TEST</td>" . PHP_EOL . "<td title=\"Message\">testmessage</td>" . PHP_EOL . "</tr>" . PHP_EOL;
self::assertEquals($v, $e);
}
示例7: testClassnamePattern
public function testClassnamePattern()
{
$event = new LoggerLoggingEvent("LoggerLayoutPatternTest", new Logger("TEST"), LoggerLevel::getLevelError(), "testmessage");
$v = $this->formatEvent($event, '%C');
$dt = $this->getEventDateTime($event);
$e = "LoggerLayoutPatternTest";
self::assertEquals($e, $v);
}
示例8: testSimpleLayout
public function testSimpleLayout()
{
$event = new LoggerLoggingEvent("LoggerLayoutSimpleTest", new Logger("TEST"), LoggerLevel::getLevelError(), "testmessage");
$layout = new LoggerLayoutSimple();
$actual = $layout->format($event);
$expected = "ERROR - testmessage" . PHP_EOL;
self::assertEquals($expected, $actual);
}
示例9: testErrorLayout
public function testErrorLayout()
{
$event = new LoggerLoggingEvent("LoggerLayoutXml", new Logger("TEST"), LoggerLevel::getLevelError(), "testmessage");
$layout = new LoggerLayoutPattern();
$layout->setConversionPattern("%-5p %c %X{username}: %m in %F at %L%n");
$v = $layout->format($event);
$e = 'ERROR TEST : testmessage in NA at NA' . PHP_EOL;
self::assertEquals($v, $e);
}
示例10: testClassname
public function testClassname()
{
$event = new LoggerLoggingEvent("MyClass", new Logger("TEST"), LoggerLevel::getLevelError(), "testmessage");
$expected = 'MyClass';
$patternParser = new LoggerPatternParser("%C");
$c = $patternParser->parse();
$actual = '';
$c->format($actual, $event);
self::assertEquals($expected, $actual);
}
示例11: testSocketProblem
/** Tests Exception due to unreachable remote host.
*
* @expectedException LoggerException
*/
public function testSocketProblem()
{
$appender = new LoggerAppenderSocket("myname ");
$appender->setDry(false);
$appender->setRemoteHost("does.not.exists");
$appender->setPort(1234);
$appender->activateOptions();
$event = new LoggerLoggingEvent("LoggerAppenderSocketTest", new Logger("TEST"), LoggerLevel::getLevelError(), "testmessage");
$appender->append($event);
}
示例12: testDecide
public function testDecide()
{
$filter = new LoggerFilterDenyAll();
$eventError = new LoggerLoggingEvent("LoggerAppenderEchoTest", new Logger("TEST"), LoggerLevel::getLevelError(), "testmessage");
$eventDebug = new LoggerLoggingEvent("LoggerAppenderEchoTest", new Logger("TEST"), LoggerLevel::getLevelDebug(), "testmessage");
$eventWarn = new LoggerLoggingEvent("LoggerAppenderEchoTest", new Logger("TEST"), LoggerLevel::getLevelWarn(), "testmessage");
$result = $filter->decide($eventError);
self::assertEquals($result, LoggerFilter::DENY);
$result = $filter->decide($eventDebug);
self::assertEquals($result, LoggerFilter::DENY);
$result = $filter->decide($eventWarn);
self::assertEquals($result, LoggerFilter::DENY);
}
示例13: append
public function append(LoggerLoggingEvent $event)
{
$level = $event->getLevel();
if ($level->isGreaterOrEqual(LoggerLevel::getLevelError())) {
trigger_error($this->layout->format($event), E_USER_ERROR);
} else {
if ($level->isGreaterOrEqual(LoggerLevel::getLevelWarn())) {
trigger_error($this->layout->format($event), E_USER_WARNING);
} else {
trigger_error($this->layout->format($event), E_USER_NOTICE);
}
}
}
示例14: testPhp
public function testPhp()
{
$appender = new LoggerAppenderPhp("TEST");
$layout = new LoggerLayoutSimple();
$appender->setLayout($layout);
$appender->activateOptions();
$event = new LoggerLoggingEvent("LoggerAppenderPhpTest", new Logger("TEST"), LoggerLevel::getLevelError(), "testmessage");
$appender->append($event);
$event = new LoggerLoggingEvent("LoggerAppenderPhpTest", new Logger("TEST"), LoggerLevel::getLevelWarn(), "testmessage");
$appender->append($event);
$event = new LoggerLoggingEvent("LoggerAppenderPhpTest", new Logger("TEST"), LoggerLevel::getLevelDebug(), "testmessage");
$appender->append($event);
}
示例15: testErrorLayout
public function testErrorLayout()
{
$event = new LoggerLoggingEvent("LoggerLayoutTTCC", new Logger("TEST"), LoggerLevel::getLevelError(), "testmessage");
$layout = new LoggerLayoutTTCC();
$v = $layout->format($event);
$pos = strpos($v, "[" . $event->getThreadName() . "] ERROR TEST - testmessage");
if ($pos === false) {
self::assertTrue(false);
} else {
if ($pos === true) {
self::assertTrue(true);
}
}
}