コード例 #1
0
ファイル: class_log.php プロジェクト: JDevelopers/Mail
 /**
  * @access private
  * @param string $errorDesc
  * @param int $line
  */
 function _writeLine($errorDesc, $line)
 {
     static $_isFirst = true;
     static $_lastTime;
     if ($_isFirst) {
         $_ftime = date('d/m/Y H:i:s');
         $_uri = isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : '';
         $_isFirst = false;
         $_post = isset($_POST) && count($_POST) > 0 ? ' [POST(' . count($_POST) . ')]' : '';
         @error_log("\r\n" . '[' . $_ftime . '] URL ' . $_uri . $_post . "\r\n", 3, $this->LogFilePath);
         $_server = isset($_SERVER['SERVER_SOFTWARE']) ? ', ' . $_SERVER['SERVER_SOFTWARE'] : '';
         @error_log('[' . $_ftime . '] INFO > ver.' . WMVERSION . ', PHP-' . phpversion() . $_server . "\r\n", 3, $this->LogFilePath);
         if (strlen($_post) > 0) {
             @error_log('[' . $_ftime . '] POST > [' . implode(', ', array_keys($_POST)) . "]\r\n", 3, $this->LogFilePath);
         }
     }
     if (LOG_LINELIMIT && strlen($errorDesc) > LOG_LINELIMIT * 2) {
         $errorDesc = substr($errorDesc, 0, LOG_LINELIMIT) . "\r\n ----------- cut ------------ \r\n" . substr($errorDesc, -(int) ceil(LOG_LINELIMIT / 2));
     }
     $line = strlen($line) > 0 ? '[line: ' . $line . ']' : '';
     $_newTime = CLog::getmicrotime();
     $_newSTime = (int) (CLog::getmicrosec() * 1000);
     $_tmpTime = (int) (($_newTime - $_lastTime) * 1000);
     $_pref = '';
     if ($_lastTime && $_tmpTime > LOG_TIMERUN) {
         $_pref = $_tmpTime . '::';
     }
     $_lastTime = $_newTime;
     @error_log($_pref . '[' . date('H:i:s', $_newTime) . '.' . $_newSTime . ']' . $line . ' ' . $errorDesc . "\r\n", 3, $this->LogFilePath);
 }