Fix output message in log rotation job
This commit is contained in:
parent
7e5c3cc807
commit
200fd88132
@ -686,6 +686,7 @@ class Utils
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(! function_exists('gzopen')) {
|
if(! function_exists('gzopen')) {
|
||||||
|
$this->error = 'Support for gzopen not available in this PHP';
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -710,7 +711,7 @@ class Utils
|
|||||||
$logname = $file['name'];
|
$logname = $file['name'];
|
||||||
$logpath = $file['path'];
|
$logpath = $file['path'];
|
||||||
|
|
||||||
// Handle already compressed files
|
// Handle already compressed files to rename them and add +1
|
||||||
|
|
||||||
$filter = '^'.preg_quote($logname, '/').'\.([0-9]+)\.gz$';
|
$filter = '^'.preg_quote($logname, '/').'\.([0-9]+)\.gz$';
|
||||||
|
|
||||||
@ -741,18 +742,19 @@ class Utils
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Compress last save
|
// Compress last save
|
||||||
|
|
||||||
if (dol_is_file($logpath.'/'.$logname.'.1')) {
|
if (dol_is_file($logpath.'/'.$logname.'.1')) {
|
||||||
if($nbSaves > 1) {
|
if($nbSaves > 1) {
|
||||||
$gzfilehandle = gzopen($logpath.'/'.$logname.'.2.gz', 'wb9');
|
$gzfilehandle = gzopen($logpath.'/'.$logname.'.2.gz', 'wb9');
|
||||||
|
|
||||||
if (empty($gzfilehandle)) {
|
if (empty($gzfilehandle)) {
|
||||||
|
$this->error = 'Failted to open file '.$logpath.'/'.$logname.'.2.gz';
|
||||||
return -3;
|
return -3;
|
||||||
}
|
}
|
||||||
|
|
||||||
$sourcehandle = fopen($logpath.'/'.$logname.'.1', 'r');
|
$sourcehandle = fopen($logpath.'/'.$logname.'.1', 'r');
|
||||||
|
|
||||||
if (empty($sourcehandle)) {
|
if (empty($sourcehandle)) {
|
||||||
|
$this->error = 'Failed to open file '.$logpath.'/'.$logname.'.1';
|
||||||
return -4;
|
return -4;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -770,13 +772,15 @@ class Utils
|
|||||||
// Compress current file et recreate it
|
// Compress current file et recreate it
|
||||||
|
|
||||||
if (dol_is_file($logpath.'/'.$logname)) {
|
if (dol_is_file($logpath.'/'.$logname)) {
|
||||||
if(dol_move($logpath.'/'.$logname, $logpath.'/'.$logname.'.1', 0, 1, 0, 0)) {
|
if (dol_move($logpath.'/'.$logname, $logpath.'/'.$logname.'.1', 0, 1, 0, 0))
|
||||||
|
{
|
||||||
$newlog = fopen($logpath.'/'.$logname, 'a+');
|
$newlog = fopen($logpath.'/'.$logname, 'a+');
|
||||||
fclose($newlog);
|
fclose($newlog);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$this->output = 'Archive log files (keeping last SYSLOG_FILE_SAVES='.$nbSaves.' files) done.';
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -82,7 +82,7 @@ class modSyslog extends DolibarrModules
|
|||||||
|
|
||||||
// Cronjobs
|
// Cronjobs
|
||||||
$this->cronjobs = array(
|
$this->cronjobs = array(
|
||||||
0=>array('label'=>'CompressSyslogs', 'jobtype'=>'method', 'class'=>'core/class/utils.class.php', 'objectname'=>'Utils', 'method'=>'compressSyslogs', 'parameters'=>'', 'comment'=>'PurgeDeleteTemporaryFiles', 'frequency'=>1, 'unitfrequency'=> 3600 * 24, 'priority'=>50, 'status'=>0, 'test'=>true),
|
0=>array('label'=>'CompressSyslogs', 'jobtype'=>'method', 'class'=>'core/class/utils.class.php', 'objectname'=>'Utils', 'method'=>'compressSyslogs', 'parameters'=>'', 'comment'=>'Compress and archive log files', 'frequency'=>1, 'unitfrequency'=> 3600 * 24, 'priority'=>50, 'status'=>0, 'test'=>true),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user