本文整理匯總了PHP中Monolog\Handler\RotatingFileHandler::write方法的典型用法代碼示例。如果您正苦於以下問題:PHP RotatingFileHandler::write方法的具體用法?PHP RotatingFileHandler::write怎麽用?PHP RotatingFileHandler::write使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Monolog\Handler\RotatingFileHandler
的用法示例。
在下文中一共展示了RotatingFileHandler::write方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: testReuseCurrentFile
public function testReuseCurrentFile()
{
$log = __DIR__ . '/Fixtures/foo-' . date('Y-m-d') . '.rot';
file_put_contents($log, "foo");
$handler = new RotatingFileHandler(__DIR__ . '/Fixtures/foo.rot');
$handler->write(array('message' => 'test'));
$this->assertEquals('footest', file_get_contents($log));
}
示例2: write
/**
* {@inheritdoc}
*/
protected function write(array $record)
{
if (!file_exists($this->url)) {
touch($this->url);
// Create blank file
chmod($this->url, 0777);
}
parent::write($record);
}
示例3: writeWithRotation
/**
* Writes the log record to a separate rotatingFileHandler
*
* @param $record array
* @return void
*/
public function writeWithRotation(array $record)
{
$logDir = $this->filesystem->getParentDirectory($this->url);
if (!$this->filesystem->isDirectory($logDir)) {
$this->filesystem->createDirectory($logDir, DriverInterface::WRITEABLE_DIRECTORY_MODE);
}
// make sure the handler is at least there
if ($this->rotatingFileHandler != null) {
$this->rotatingFileHandler->write($record);
} else {
// write the log somewhere
$record['message'] .= ' - ERROR ROTATING LOG FILE';
parent::write($record);
}
}