本文整理汇总了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);
}
}