当前位置: 首页>>代码示例>>PHP>>正文


PHP eZDebug::maxLogSize方法代码示例

本文整理汇总了PHP中eZDebug::maxLogSize方法的典型用法代码示例。如果您正苦于以下问题:PHP eZDebug::maxLogSize方法的具体用法?PHP eZDebug::maxLogSize怎么用?PHP eZDebug::maxLogSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在eZDebug的用法示例。


在下文中一共展示了eZDebug::maxLogSize方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: writeFile

 function writeFile(&$logFileData, &$string, $verbosityLevel, $alwaysLog = false)
 {
     $enabled = eZDebug::isDebugEnabled();
     if (!$alwaysLog and !$enabled) {
         return;
     }
     if (!$alwaysLog and !$this->isLogFileEnabled($verbosityLevel)) {
         return;
     }
     $oldHandleType = eZDebug::setHandleType(self::HANDLE_TO_PHP);
     $logDir = $logFileData[0];
     $logName = $logFileData[1];
     $fileName = $logDir . $logName;
     if (!file_exists($logDir)) {
         //include_once( 'lib/ezfile/classes/ezdir.php' );
         eZDir::mkdir($logDir, 0775, true);
     }
     $oldumask = @umask(0);
     $fileExisted = @file_exists($fileName);
     if ($fileExisted and filesize($fileName) > eZDebug::maxLogSize()) {
         if (eZDebug::rotateLog($fileName)) {
             $fileExisted = false;
         }
     }
     $logFile = @fopen($fileName, "a");
     if ($logFile) {
         $time = strftime("%b %d %Y %H:%M:%S", strtotime("now"));
         $ip = eZSys::serverVariable('REMOTE_ADDR', true);
         if (!$ip) {
             $ip = eZSys::serverVariable('HOSTNAME', true);
         }
         $notice = "[ " . $time . " ] [" . $ip . "] " . $string . "\n";
         @fwrite($logFile, $notice);
         @fclose($logFile);
         if (!$fileExisted) {
             @chmod($fileName, 0664);
         }
         @umask($oldumask);
     } else {
         @umask($oldumask);
         $logEnabled = $this->isLogFileEnabled($verbosityLevel);
         $this->setLogFileEnabled(false, $verbosityLevel);
         if ($verbosityLevel != self::LEVEL_ERROR or $logEnabled) {
             eZDebug::setHandleType($oldHandleType);
             $this->writeError("Cannot open log file '{$fileName}' for writing\n" . "The web server must be allowed to modify the file.\n" . "File logging for '{$fileName}' is disabled.", 'eZDebug::writeFile');
         }
     }
     eZDebug::setHandleType($oldHandleType);
 }
开发者ID:BGCX067,项目名称:ezfire-svn-to-git,代码行数:49,代码来源:ezdebug.php

示例2: writeFile

 function writeFile(&$logFileData, &$string, $verbosityLevel, $alwaysLog = false)
 {
     $enabled = eZDebug::isDebugEnabled();
     if (!$alwaysLog and !$enabled) {
         return;
     }
     if (!$alwaysLog and !$this->isLogFileEnabled($verbosityLevel)) {
         return;
     }
     $oldHandleType = eZDebug::setHandleType(self::HANDLE_TO_PHP);
     $logDir = $logFileData[0];
     $logName = $logFileData[1];
     $fileName = $logDir . $logName;
     if (!file_exists($logDir)) {
         eZDir::mkdir($logDir, false, true);
     }
     $oldumask = @umask(0);
     clearstatcache(true, $fileName);
     $fileExisted = file_exists($fileName);
     if ($fileExisted and filesize($fileName) > eZDebug::maxLogSize()) {
         if (eZDebug::rotateLog($fileName)) {
             $fileExisted = false;
         }
     }
     $logFile = @fopen($fileName, "a");
     if ($logFile) {
         $time = strftime("%b %d %Y %H:%M:%S", strtotime("now"));
         $ip = eZSys::clientIP();
         if (!$ip) {
             $ip = eZSys::serverVariable('HOSTNAME', true);
         }
         $notice = "[ " . $time . " ] [" . $ip . "] " . $string . "\n";
         @fwrite($logFile, $notice);
         @fclose($logFile);
         if (!$fileExisted) {
             $ini = eZINI::instance();
             $permissions = octdec($ini->variable('FileSettings', 'LogFilePermissions'));
             @chmod($fileName, $permissions);
         }
         @umask($oldumask);
     } else {
         @umask($oldumask);
         $logEnabled = $this->isLogFileEnabled($verbosityLevel);
         $this->setLogFileEnabled(false, $verbosityLevel);
         if ($verbosityLevel != self::LEVEL_ERROR or $logEnabled) {
             eZDebug::setHandleType($oldHandleType);
             $this->writeError("Cannot open log file '{$fileName}' for writing\n" . "The web server must be allowed to modify the file.\n" . "File logging for '{$fileName}' is disabled.", 'eZDebug::writeFile');
         }
     }
     eZDebug::setHandleType($oldHandleType);
 }
开发者ID:schwabokaner,项目名称:ezpublish-legacy,代码行数:51,代码来源:ezdebug.php

示例3:

<?php

/**
 * Rotate logs of ws calls: since we store them in the per-sa dir, eZ will not do it on its own.
 *
 * We are very nice people, and allow a custom max file size to be specified
 * instead of relying on eZ default one, and a number of rotated files to be kept, too!
 *
 * @author G. Giunta
 * @copyright (C) 2009-2016 G. Giunta
 */
$ini = eZINI::instance('wsproviders.ini');
$maxFileSize = $ini->variable('GeneralSettings', 'MaxLogSize');
if ($maxFileSize <= 0) {
    // in case ini setting is missing
    $maxFileSize = eZDebug::maxLogSize();
}
if ($ini->hasVariable('GeneralSettings', 'MaxLogrotateFiles') && $ini->variable('GeneralSettings', 'MaxLogrotateFiles') > 0) {
    $defaultrotate = eZDebug::maxLogrotateFiles();
    eZDebug::setLogrotateFiles($ini->variable('GeneralSettings', 'MaxLogrotateFiles'));
}
$varDir = eZSys::varDirectory();
$logDir = 'log';
$logName = 'webservices.log';
$fileName = $varDir . '/' . $logDir . '/' . $logName;
if (file_exists($fileName) && filesize($fileName) > $maxFileSize) {
    eZDebug::rotateLog($fileName);
}
if (isset($defaultrotate)) {
    eZDebug::setLogrotateFiles($defaultrotate);
}
开发者ID:gggeek,项目名称:ggwebservices,代码行数:31,代码来源:rotatewslogs.php


注:本文中的eZDebug::maxLogSize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。