Merge pull request #2164 from gproly/BUG-13506

Bug 13506 SOLVED La sección ADMIN / Logs, opción Cron, se queda cargando y en consola de navegador se muestra el error 500 internal Server Error.
This commit is contained in:
julceslauhub
2013-11-26 07:22:17 -08:00
8 changed files with 161 additions and 18 deletions

View File

@@ -895,12 +895,7 @@ function saveLog($sSource, $sType, $sDescription)
}
G::verifyPath(PATH_DATA . "log" . PATH_SEP, true);
//setExecutionMessage( PATH_DATA."log".PATH_SEP);
$oFile = @fopen(PATH_DATA . "log" . PATH_SEP . "cron.log", "a+");
@fwrite($oFile, date("Y-m-d H:i:s") . " | $sObject | " . $sSource . " | $sType | " . $sDescription . "\n");
@fclose($oFile);
G::log(date("Y-m-d H:i:s") . " | $sObject | " . $sSource . " | $sType | " . $sDescription . "\n", PATH_DATA);
} catch (Exception $e) {
//CONTINUE
}

View File

@@ -336,17 +336,15 @@ function saveLog($sSource, $sType, $sDescription)
global $isDebug;
if ($isDebug)
print date ('H:i:s') . " ($sSource) $sType $sDescription <br>\n";
@fwrite ($oFile, date ('Y-m-d H:i:s') . '(' . $sSource . ') ' . $sDescription . "\n");
G::verifyPath (PATH_DATA . 'log' . PATH_SEP, true);
$message = date ('Y-m-d H:i:s') . '(' . $sSource . ') ' . $sDescription . "\n";
if ($sType == 'action') {
$oFile = @fopen (PATH_DATA . 'log' . PATH_SEP . 'cron.log', 'a+');
G::log($message, PATH_DATA);
}
else {
$oFile = @fopen (PATH_DATA . 'log' . PATH_SEP . 'cronError.log', 'a+');
G::log($message, PATH_DATA, 'cronError.log');
}
@fwrite ($oFile, date ('Y-m-d H:i:s') . '(' . $sSource . ') ' . $sDescription . "\n");
@fclose ($oFile);
}
catch (Exception $oError) {
// CONTINUE

View File

@@ -515,17 +515,15 @@ function saveLog($sSource, $sType, $sDescription)
global $isDebug;
if ($isDebug)
print date ('H:i:s') . " ($sSource) $sType $sDescription <br>\n";
@fwrite ($oFile, date ('Y-m-d H:i:s') . '(' . $sSource . ') ' . $sDescription . "\n");
G::verifyPath (PATH_DATA . 'log' . PATH_SEP, true);
$message = date ('Y-m-d H:i:s') . '(' . $sSource . ') ' . $sDescription . "\n";
if ($sType == 'action') {
$oFile = @fopen (PATH_DATA . 'log' . PATH_SEP . 'cron.log', 'a+');
G::log($message, PATH_DATA);
}
else {
$oFile = @fopen (PATH_DATA . 'log' . PATH_SEP . 'cronError.log', 'a+');
G::log($message, PATH_DATA, 'cronError.log');
}
@fwrite ($oFile, date ('Y-m-d H:i:s') . '(' . $sSource . ') ' . $sDescription . "\n");
@fclose ($oFile);
}
catch (Exception $oError) {
// CONTINUE

View File

@@ -1084,7 +1084,7 @@ class System
}
// default configuration
$config = array ('debug' => 0,'debug_sql' => 0,'debug_time' => 0,'debug_calendar' => 0,'wsdl_cache' => 1,'memory_limit' => "256M", 'time_zone' => 'America/New_York','memcached' => 0,'memcached_server' => '','default_skin' => 'neoclassic','default_lang' => 'en','proxy_host' => '','proxy_port' => '','proxy_user' => '','proxy_pass' => '');
$config = array('debug' => 0, 'debug_sql' => 0, 'debug_time' => 0, 'debug_calendar' => 0, 'wsdl_cache' => 1, 'memory_limit' => "256M", 'time_zone' => 'America/New_York', 'memcached' => 0, 'memcached_server' => '', 'default_skin' => 'neoclassic', 'default_lang' => 'en', 'proxy_host' => '', 'proxy_port' => '', 'proxy_user' => '', 'proxy_pass' => '', 'size_log_file' => 5000000, 'number_log_file' => 5);
// read the global env.ini configuration file
if ($readGlobalIniFile && ($globalConf = @parse_ini_file( $globalIniFile )) !== false) {

View File

@@ -89,6 +89,13 @@ class workspaceTools
$stop = microtime(true);
$final = $stop - $start;
CLI::logging("<*> Updating cache view Process took $final seconds.\n");
$start = microtime(true);
CLI::logging("> Backup log files...\n");
$this->backupLogFiles();
$stop = microtime(true);
$final = $stop - $start;
CLI::logging("<*> Backup log files Process took $final seconds.\n");
}
/**
@@ -1424,5 +1431,21 @@ class workspaceTools
return $result;
}
public function backupLogFiles()
{
$config = System::getSystemConfiguration();
clearstatcache();
$path = PATH_DATA . "log" . PATH_SEP;
$filePath = $path . "cron.log";
if (file_exists($filePath)) {
$size = filesize($filePath);
/* $config['size_log_file'] has the value 5000000 -> approximately 5 megabytes */
if ($size > $config['size_log_file']) {
rename($filePath, $filePath . ".bak");
}
}
}
}