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