本文整理汇总了PHP中Monolog\Handler\RotatingFileHandler::close方法的典型用法代码示例。如果您正苦于以下问题:PHP RotatingFileHandler::close方法的具体用法?PHP RotatingFileHandler::close怎么用?PHP RotatingFileHandler::close使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Monolog\Handler\RotatingFileHandler
的用法示例。
在下文中一共展示了RotatingFileHandler::close方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testRotation
/**
* @dataProvider rotationTests
*/
public function testRotation($createFile)
{
touch($old1 = __DIR__ . '/Fixtures/foo-' . date('Y-m-d', time() - 86400) . '.rot');
touch($old2 = __DIR__ . '/Fixtures/foo-' . date('Y-m-d', time() - 86400 * 2) . '.rot');
touch($old3 = __DIR__ . '/Fixtures/foo-' . date('Y-m-d', time() - 86400 * 3) . '.rot');
touch($old4 = __DIR__ . '/Fixtures/foo-' . date('Y-m-d', time() - 86400 * 4) . '.rot');
$log = __DIR__ . '/Fixtures/foo-' . date('Y-m-d') . '.rot';
if ($createFile) {
touch($log);
}
$handler = new RotatingFileHandler(__DIR__ . '/Fixtures/foo.rot', 2);
$handler->write(array('message' => 'test'));
$handler->close();
$this->assertTrue(file_exists($log));
$this->assertTrue(file_exists($old1));
$this->assertEquals($createFile, file_exists($old2));
$this->assertEquals($createFile, file_exists($old3));
$this->assertEquals($createFile, file_exists($old4));
$this->assertEquals('test', file_get_contents($log));
}
示例2: testRotation
/**
* @dataProvider rotationTests
*/
public function testRotation($createFile)
{
touch($old1 = __DIR__ . '/Fixtures/foo-' . date('Y-m-d', time() - 86400) . '.rot');
touch($old2 = __DIR__ . '/Fixtures/foo-' . date('Y-m-d', time() - 86400 * 2) . '.rot');
touch($old3 = __DIR__ . '/Fixtures/foo-' . date('Y-m-d', time() - 86400 * 3) . '.rot');
touch($old4 = __DIR__ . '/Fixtures/foo-' . date('Y-m-d', time() - 86400 * 4) . '.rot');
$log = __DIR__ . '/Fixtures/foo-' . date('Y-m-d') . '.rot';
if ($createFile) {
touch($log);
}
$handler = new RotatingFileHandler(__DIR__ . '/Fixtures/foo.rot', 2);
$handler->setFormatter($this->getIdentityFormatter());
$handler->handle($this->getRecord());
$handler->close();
$this->assertTrue(file_exists($log));
$this->assertTrue(file_exists($old1));
$this->assertEquals($createFile, file_exists($old2));
$this->assertEquals($createFile, file_exists($old3));
$this->assertEquals($createFile, file_exists($old4));
$this->assertEquals('test', file_get_contents($log));
}
示例3: testRotation
/**
* @dataProvider rotationTests
*/
public function testRotation($createFile, $dateFormat, $timeCallback)
{
touch($old1 = __DIR__ . '/Fixtures/foo-' . date($dateFormat, $timeCallback(-1)) . '.rot');
touch($old2 = __DIR__ . '/Fixtures/foo-' . date($dateFormat, $timeCallback(-2)) . '.rot');
touch($old3 = __DIR__ . '/Fixtures/foo-' . date($dateFormat, $timeCallback(-3)) . '.rot');
touch($old4 = __DIR__ . '/Fixtures/foo-' . date($dateFormat, $timeCallback(-4)) . '.rot');
$log = __DIR__ . '/Fixtures/foo-' . date($dateFormat) . '.rot';
if ($createFile) {
touch($log);
}
$handler = new RotatingFileHandler(__DIR__ . '/Fixtures/foo.rot', 2);
$handler->setFormatter($this->getIdentityFormatter());
$handler->setFilenameFormat('{filename}-{date}', $dateFormat);
$handler->handle($this->getRecord());
$handler->close();
$this->assertTrue(file_exists($log));
$this->assertTrue(file_exists($old1));
$this->assertEquals($createFile, file_exists($old2));
$this->assertEquals($createFile, file_exists($old3));
$this->assertEquals($createFile, file_exists($old4));
$this->assertEquals('test', file_get_contents($log));
}