Example #1
0
 /**
  * @param jILogMessage $message the message to log
  */
 function logMessage($message)
 {
     global $gJConfig, $gJCoord;
     if (!is_writable(jApp::logPath())) {
         return;
     }
     $type = $message->getCategory();
     if ($gJCoord && $gJCoord->request) {
         $conf =& $gJConfig->fileLogger;
         if (!isset($conf[$type])) {
             return;
         }
         $f = $conf[$type];
         $ip = $gJCoord->request->getIP();
         $f = str_replace('%ip%', $ip, $f);
         $f = str_replace('%m%', date("m"), $f);
         $f = str_replace('%Y%', date("Y"), $f);
         $f = str_replace('%d%', date("d"), $f);
         $f = str_replace('%H%', date("H"), $f);
     } else {
         // if there isn't a request, so jLog is called for an error during the construction
         // of the coordinator
         $f = 'errors.log';
         $ip = isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : '127.0.0.1';
     }
     try {
         $sel = new jSelectorLog($f);
         $file = $sel->getPath();
         @error_log(date("Y-m-d H:i:s") . "\t" . $ip . "\t{$type}\t" . $message->getFormatedMessage() . "\n", 3, $file);
     } catch (Exception $e) {
         $file = jApp::logPath('errors.log');
         @error_log(date("Y-m-d H:i:s") . "\t" . $ip . "\terror\t" . $e->getMessage() . "\n", 3, $file);
     }
 }
Example #2
0
 /**
  * log a message
  * @param mixed $message
  * @param string $type the log type
  */
 public static function log($message, $type = 'default')
 {
     $f = $GLOBALS['gJConfig']->logfiles[$type];
     if ($f[0] == '!') {
         $GLOBALS['gJCoord']->addLogMsg("log {$type}: {$message}", substr($f, 1));
     } else {
         if (!isset($_SERVER['REMOTE_ADDR'])) {
             // for CLI mode (bug #111)
             $_SERVER['REMOTE_ADDR'] = '127.0.0.1';
         }
         $f = str_replace('%ip%', $_SERVER['REMOTE_ADDR'], $f);
         $f = str_replace('%m%', date("m"), $f);
         $f = str_replace('%Y%', date("Y"), $f);
         $f = str_replace('%d%', date("d"), $f);
         $f = str_replace('%H%', date("H"), $f);
         $sel = new jSelectorLog($f);
         error_log(date("Y-m-d H:i:s") . "\t" . $_SERVER['REMOTE_ADDR'] . "\t{$type}\t{$message}\n", 3, $sel->getPath());
     }
 }
 /**
  * @param jILogMessage $message the message to log
  */
 function logMessage($message)
 {
     if (!is_writable(jApp::logPath())) {
         return;
     }
     $type = $message->getCategory();
     $appConf = jApp::config();
     if ($appConf) {
         $conf =& jApp::config()->fileLogger;
         if (!isset($conf[$type])) {
             return;
         }
         $f = $conf[$type];
         $f = str_replace('%m%', date("m"), $f);
         $f = str_replace('%Y%', date("Y"), $f);
         $f = str_replace('%d%', date("d"), $f);
         $f = str_replace('%H%', date("H"), $f);
     } else {
         $f = 'errors.log';
     }
     $coord = jApp::coord();
     if ($coord && $coord->request) {
         $ip = $coord->request->getIP();
     } else {
         $ip = isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : '127.0.0.1';
     }
     $f = str_replace('%ip%', $ip, $f);
     try {
         $sel = new jSelectorLog($f);
         $file = $sel->getPath();
         @error_log(date("Y-m-d H:i:s") . "\t" . $ip . "\t{$type}\t" . $message->getFormatedMessage() . "\n", 3, $file);
         @chmod($file, jApp::config()->chmodFile);
     } catch (Exception $e) {
         $file = jApp::logPath('errors.log');
         @error_log(date("Y-m-d H:i:s") . "\t" . $ip . "\terror\t" . $e->getMessage() . "\n", 3, $file);
         @chmod($file, jApp::config()->chmodFile);
     }
 }