本文整理汇总了PHP中Monolog\Handler\ErrorLogHandler::handle方法的典型用法代码示例。如果您正苦于以下问题:PHP ErrorLogHandler::handle方法的具体用法?PHP ErrorLogHandler::handle怎么用?PHP ErrorLogHandler::handle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Monolog\Handler\ErrorLogHandler
的用法示例。
在下文中一共展示了ErrorLogHandler::handle方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testShouldLogMessagesUsingErrorLogFuncion
/**
* @covers Monolog\Handler\ErrorLogHandler::write
*/
public function testShouldLogMessagesUsingErrorLogFuncion()
{
$type = ErrorLogHandler::OPERATING_SYSTEM;
$handler = new ErrorLogHandler($type);
$handler->handle($this->getRecord(Logger::ERROR));
$this->assertStringMatchesFormat('[%s] test.ERROR: test [] []', $GLOBALS['error_log'][0]);
$this->assertSame($GLOBALS['error_log'][1], $type);
}
示例2: handle
public function handle(array $record)
{
if ($record['channel'] === $this->appName) {
$this->setFormatter($this->defaultFormatter);
$record['filename'] = strtolower($record['level_name']);
} else {
$this->setFormatter($this->priorityFormatter);
$record['filename'] = $record['channel'];
}
return parent::handle($record);
}
示例3: testShouldLogMessagesUsingErrorLogFuncion
/**
* @covers Monolog\Handler\ErrorLogHandler::write
*/
public function testShouldLogMessagesUsingErrorLogFuncion()
{
$type = ErrorLogHandler::OPERATING_SYSTEM;
$handler = new ErrorLogHandler($type);
$handler->setFormatter(new LineFormatter('%channel%.%level_name%: %message% %context% %extra%', null, true));
$handler->handle($this->getRecord(Logger::ERROR, "Foo\nBar\r\n\r\nBaz"));
$this->assertSame("test.ERROR: Foo\nBar\r\n\r\nBaz [] []", $GLOBALS['error_log'][0][0]);
$this->assertSame($GLOBALS['error_log'][0][1], $type);
$handler = new ErrorLogHandler($type, Logger::DEBUG, true, true);
$handler->setFormatter(new LineFormatter(null, null, true));
$handler->handle($this->getRecord(Logger::ERROR, "Foo\nBar\r\n\r\nBaz"));
$this->assertStringMatchesFormat('[%s] test.ERROR: Foo', $GLOBALS['error_log'][1][0]);
$this->assertSame($GLOBALS['error_log'][1][1], $type);
$this->assertStringMatchesFormat('Bar', $GLOBALS['error_log'][2][0]);
$this->assertSame($GLOBALS['error_log'][2][1], $type);
$this->assertStringMatchesFormat('Baz [] []', $GLOBALS['error_log'][3][0]);
$this->assertSame($GLOBALS['error_log'][3][1], $type);
}