--- /tmp/dsg/dolibarr/htdocs/core/modules/syslog/github_19.0.3_mod_syslog_file.php +++ /tmp/dsg/dolibarr/htdocs/core/modules/syslog/client_mod_syslog_file.php @@ -10,2 +10,2 @@ - public $code = 'file'; - public $lastTime = 0; + public $code = 'file'; + public $lastTime = 0; @@ -54,2 +54,2 @@ - global $conf; - return !getDolGlobalString('SYSLOG_DISABLE_LOGHANDLER_FILE') ? 1 : 0; // Set SYSLOG_DISABLE_LOGHANDLER_FILE to 1 to disable this loghandler + global $conf; + return empty($conf->global->SYSLOG_DISABLE_LOGHANDLER_FILE) ? 1 : 0; // Set SYSLOG_DISABLE_LOGHANDLER_FILE to 1 to disable this loghandler @@ -72 +72 @@ - 'css' => 'minwidth300 maxwidth500' + 'attr' => 'size="60"' @@ -90 +90,2 @@ - if (file_exists($filename) && is_writable($filename)) { + if (file_exists($filename) && is_writable($filename)) + { @@ -92,2 +92,0 @@ - } else { - $errors[] = $langs->trans("ErrorFailedToOpenFile", $filename); @@ -94,0 +94 @@ + else $errors[] = $langs->trans("ErrorFailedToOpenFile", $filename); @@ -107 +107 @@ - global $conf; + global $conf; @@ -109,5 +109,2 @@ - if (!getDolGlobalString('SYSLOG_FILE')) { - $tmp = DOL_DATA_ROOT.'/dolibarr.log'; - } else { - $tmp = str_replace('DOL_DATA_ROOT', DOL_DATA_ROOT, $conf->global->SYSLOG_FILE); - } + if (empty($conf->global->SYSLOG_FILE)) $tmp = DOL_DATA_ROOT.'/dolibarr.log'; + else $tmp = str_replace('DOL_DATA_ROOT', DOL_DATA_ROOT, $conf->global->SYSLOG_FILE); @@ -115,12 +112,11 @@ - if (getDolGlobalString('SYSLOG_FILE_ONEPERSESSION')) { - if (is_numeric($conf->global->SYSLOG_FILE_ONEPERSESSION)) { - if (getDolGlobalInt('SYSLOG_FILE_ONEPERSESSION') == 1) { // file depend on instance session key name (Note that session name is same for the instance so for all users and is not a per user value) - $suffixinfilename .= '_'.session_name(); - } - if (getDolGlobalInt('SYSLOG_FILE_ONEPERSESSION') == 2) { // file depend on instance session key name + ip so nearly per user - $suffixinfilename .= '_'.session_name().'_'.$_SERVER["REMOTE_ADDR"]; - } - } else { - $suffixinfilename .= '_' . getDolGlobalString('SYSLOG_FILE_ONEPERSESSION'); - } - } + if (!empty($conf->global->SYSLOG_FILE_ONEPERSESSION)) + { + if ($conf->global->SYSLOG_FILE_ONEPERSESSION == 1) // file depend on session key name (Note that session name is same for all users and is not a per user value) + { + $suffixinfilename .= '_'.session_name(); + } + if ($conf->global->SYSLOG_FILE_ONEPERSESSION == 2) // file depend on session value sor per user + { + $suffixinfilename .= '_'.session_name().'_'.$_SERVER["REMOTE_ADDR"]; + } + } @@ -128 +124 @@ - return $suffixinfilename ? preg_replace('/\.log$/i', $suffixinfilename.'.log', $tmp) : $tmp; + return $suffixinfilename ?preg_replace('/\.log$/i', $suffixinfilename.'.log', $tmp) : $tmp; @@ -142,3 +138 @@ - if (getDolGlobalString('MAIN_SYSLOG_DISABLE_FILE')) { - return; // Global option to disable output of this handler - } + if (!empty($conf->global->MAIN_SYSLOG_DISABLE_FILE)) return; // Global option to disable output of this handler @@ -149,5 +143,2 @@ - if (defined('SYSLOG_FILE_NO_ERROR')) { - $filefd = @fopen($logfile, 'a+'); - } else { - $filefd = fopen($logfile, 'a+'); - } + if (defined('SYSLOG_FILE_NO_ERROR')) $filefd = @fopen($logfile, 'a+'); + else $filefd = fopen($logfile, 'a+'); @@ -155,2 +146,4 @@ - if (!$filefd) { - if (!defined('SYSLOG_FILE_NO_ERROR') || !constant('SYSLOG_FILE_NO_ERROR')) { + if (!$filefd) + { + if (!defined('SYSLOG_FILE_NO_ERROR') || !constant('SYSLOG_FILE_NO_ERROR')) + { @@ -159 +152 @@ - print 'Failed to open log file '.($dolibarr_main_prod ? basename($logfile) : $logfile); + print 'Failed to open log file '.($dolibarr_main_prod ?basename($logfile) : $logfile); @@ -161 +154,3 @@ - } else { + } + else + { @@ -174 +169,2 @@ - if (getDolGlobalString('MAIN_SYSLOG_SHOW_DELAY')) { + if (!empty($conf->global->MAIN_SYSLOG_SHOW_DELAY)) + { @@ -180 +176 @@ - $message = dol_print_date(dol_now('gmt'), 'standard', 'gmt').$delay." ".sprintf("%-7s", $logLevels[$content['level']])." ".sprintf("%-15s", $content['ip'])." ".($this->ident > 0 ? str_pad('', $this->ident, ' ') : '').$content['message']; + $message = strftime("%Y-%m-%d %H:%M:%S", time()).$delay." ".sprintf("%-7s", $logLevels[$content['level']])." ".sprintf("%-15s", $content['ip'])." ".($this->ident > 0 ?str_pad('', $this->ident, ' ') : '').$content['message']; @@ -183 +179 @@ - dolChmod($logfile); + @chmod($logfile, octdec(empty($conf->global->MAIN_UMASK) ? '0664' : $conf->global->MAIN_UMASK)); --- /tmp/dsg/dolibarr/htdocs/core/modules/syslog/github_19.0.3_mod_syslog_syslog.php +++ /tmp/dsg/dolibarr/htdocs/core/modules/syslog/client_mod_syslog_syslog.php @@ -10 +10 @@ - public $code = 'syslog'; + public $code = 'syslog'; @@ -19 +19 @@ - return 'Syslogd'; + return 'Syslog'; @@ -51 +51 @@ - global $conf; + global $conf; @@ -54,3 +54 @@ - if (!function_exists('openlog')) { - return 0; - } + if (!function_exists('openlog')) return 0; @@ -58 +56 @@ - return !getDolGlobalString('SYSLOG_DISABLE_LOGHANDLER_SYSLOG') ? 1 : 0; // Set SYSLOG_DISABLE_LOGHANDLER_SYSLOG to 1 to disable this loghandler + return empty($conf->global->SYSLOG_DISABLE_LOGHANDLER_SYSLOG) ? 1 : 0; // Set SYSLOG_DISABLE_LOGHANDLER_SYSLOG to 1 to disable this loghandler @@ -90,2 +88,3 @@ - $facility = constant($conf->global->SYSLOG_FACILITY); - if ($facility) { + $facility = constant($conf->global->SYSLOG_FACILITY); + if ($facility) + { @@ -93,3 +92 @@ - if (!empty($_SERVER["WINDIR"])) { - $facility = constant('LOG_USER'); - } + if (!empty($_SERVER["WINDIR"])) $facility = constant('LOG_USER'); @@ -98,2 +95,4 @@ - } else { - $errors[] = $langs->trans("ErrorUnknownSyslogConstant", $facility); + } + else + { + $errors[] = $langs->trans("ErrorUnknownSyslogConstant", $facility); @@ -115,2 +114,5 @@ - if (getDolGlobalString('MAIN_SYSLOG_DISABLE_SYSLOG')) { - return; // Global option to disable output of this handler + if (!empty($conf->global->MAIN_SYSLOG_DISABLE_SYSLOG)) return; // Global option to disable output of this handler + + if (!empty($conf->global->SYSLOG_FACILITY)) // Example LOG_USER + { + $facility = constant($conf->global->SYSLOG_FACILITY); @@ -118,6 +120 @@ - - if (getDolGlobalString('SYSLOG_FACILITY')) { // Example LOG_USER - $facility = constant($conf->global->SYSLOG_FACILITY); - } else { - $facility = constant('LOG_USER'); - } + else $facility = constant('LOG_USER');