本文整理汇总了PHP中eZLog::rotateLog方法的典型用法代码示例。如果您正苦于以下问题:PHP eZLog::rotateLog方法的具体用法?PHP eZLog::rotateLog怎么用?PHP eZLog::rotateLog使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eZLog
的用法示例。
在下文中一共展示了eZLog::rotateLog方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
/**
* Executes the purge operation
*
* @todo Endless loop on fetch list. The expired items are returned over and over again
*/
public function run()
{
$cli = eZCLI::instance();
if ( $this->optMemoryMonitoring == true )
{
eZLog::rotateLog( self::LOG_FILE );
$cli->output( "Logging memory usage to " . self::LOG_FILE );
}
if ( $this->optIterationSleep > 0 )
$sleep = ( $this->optIterationSleep * 1000000 );
else
$sleep = false;
$limit = array( 0, $this->optIterationLimit );
$cli->output( "Purging expired items:" );
self::monitor( "start" );
// Fetch a limited list of purge items from the handler itself
$clusterHandler = eZClusterFileHandler::instance();
while ( $filesList = $clusterHandler->fetchExpiredItems( $this->optScopes, $limit, $this->optExpiry ) )
{
self::monitor( "iteration start" );
foreach( $filesList as $file )
{
$cli->output( "- $file" );
if ( $this->optDryRun == false )
{
self::monitor( "purge" );
$fh = eZClusterFileHandler::instance( $file );
$fh->purge( false, false );
unset( $fh );
}
}
if ( $sleep !== false )
usleep( $sleep );
// the offset only has to be increased in dry run mode
// since each batch is not deleted
if ( $this->optDryRun == true )
{
$limit[0] += $limit[1];
}
self::monitor( "iteration end" );
}
self::monitor( "end" );
}
示例2: writeStorageLog
static function writeStorageLog($name, $dir = false)
{
$ini = eZINI::instance();
$varDir = $ini->variable('FileSettings', 'VarDir');
$logDir = $ini->variable('FileSettings', 'LogDir');
$logName = 'storage.log';
$fileName = $varDir . '/' . $logDir . '/' . $logName;
$oldumask = @umask(0);
clearstatcache(true, $fileName);
$fileExisted = file_exists($fileName);
if ($fileExisted and filesize($fileName) > eZLog::maxLogSize()) {
if (eZLog::rotateLog($fileName)) {
$fileExisted = false;
}
} else {
if (!$fileExisted and !file_exists($varDir . '/' . $logDir)) {
eZDir::mkdir($varDir . '/' . $logDir, false, true);
}
}
if ($dir !== false) {
$dir = preg_replace("#/\$#", "", $dir);
$dir .= "/";
} else {
$dir = "";
}
$logFile = @fopen($fileName, "a");
if ($logFile) {
$time = strftime("%b %d %Y %H:%M:%S", strtotime("now"));
$logMessage = "[ " . $time . " ] [" . $dir . $name . "]\n";
@fwrite($logFile, $logMessage);
@fclose($logFile);
if (!$fileExisted) {
$permissions = octdec($ini->variable('FileSettings', 'LogFilePermissions'));
@chmod($fileName, $permissions);
}
@umask($oldumask);
} else {
eZDebug::writeError('Couldn\'t create the log file "' . $fileName . '"', __METHOD__);
}
}
示例3: run
/**
* Executes the purge operation
*
* @param int|null $iterationLimit Number of trashed objects to treat per iteration, use null to use a default value.
* @param int|null $sleep Number of seconds to sleep between two iterations, use null to use a default value.
*
* @return bool True if the operation succeeded.
*/
public function run($iterationLimit = 100, $sleep = 1)
{
if ($iterationLimit === null) {
$iterationLimit = 100;
}
if ($sleep === null) {
$sleep = 1;
}
if ($this->memoryMonitoring) {
eZLog::rotateLog($this->logFile);
$this->cli->output("Logging memory usage to {$this->logFile}");
}
$this->cli->output("Purging trash items:");
$this->monitor("start");
$db = eZDB::instance();
// Get user's ID who can remove subtrees. (Admin by default with userID = 14)
$userCreatorID = eZINI::instance()->variable("UserSettings", "UserCreatorID");
$user = eZUser::fetch($userCreatorID);
if (!$user) {
$this->cli->error("Cannot get user object with userID = '{$userCreatorID}'.\n(See site.ini[UserSettings].UserCreatorID)");
return false;
}
eZUser::setCurrentlyLoggedInUser($user, $userCreatorID);
$trashCount = eZContentObjectTrashNode::trashListCount(false);
if (!$this->quiet) {
$this->cli->output("Found {$trashCount} object(s) in trash.");
}
if ($trashCount == 0) {
return true;
}
if ($this->script !== null) {
$this->script->resetIteration($trashCount);
}
while ($trashCount > 0) {
$this->monitor("iteration start");
$trashList = eZContentObjectTrashNode::trashList(array('Limit' => $iterationLimit), false);
$db->begin();
foreach ($trashList as $trashNode) {
$object = $trashNode->attribute('object');
$this->monitor("purge");
$object->purge();
if ($this->script !== null) {
$this->script->iterate($this->cli, true);
}
}
if (!$db->commit()) {
$this->cli->output();
$this->cli->error('Trash has not been emptied, impossible to commit the whole transaction');
return false;
}
$trashCount = eZContentObjectTrashNode::trashListCount(false);
if ($trashCount > 0) {
eZContentObject::clearCache();
if ($sleep > 0) {
sleep($sleep);
}
}
$this->monitor("iteration end");
}
if (!$this->quiet) {
$this->cli->output('Trash successfully emptied');
}
$this->monitor("end");
return true;
}