--- /tmp/dsg/dolibarr/htdocs/core/modules/syslog/github_mod_syslog_file.php +++ /tmp/dsg/dolibarr/htdocs/core/modules/syslog/client_mod_syslog_file.php @@ -7,8 +7,8 @@ */ class mod_syslog_file extends LogHandler implements LogHandlerInterface { - public $code = 'file'; - public $lastTime = 0; + public $code = 'file'; + public $lastTime = 0; /** * Return name of logger @@ -51,7 +51,7 @@ */ public function isActive() { - global $conf; + global $conf; return empty($conf->global->SYSLOG_DISABLE_LOGHANDLER_FILE) ? 1 : 0; // Set SYSLOG_DISABLE_LOGHANDLER_FILE to 1 to disable this loghandler } @@ -90,7 +90,8 @@ if (file_exists($filename) && is_writable($filename)) { dol_syslog('admin/syslog: file '.$filename); - } else $errors[] = $langs->trans("ErrorFailedToOpenFile", $filename); + } + else $errors[] = $langs->trans("ErrorFailedToOpenFile", $filename); return $errors; } @@ -103,24 +104,24 @@ */ private function getFilename($suffixinfilename = '') { - global $conf; + global $conf; - 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); + 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); - 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"]; - } - } + 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"]; + } + } - return $suffixinfilename ?preg_replace('/\.log$/i', $suffixinfilename.'.log', $tmp) : $tmp; + return $suffixinfilename ?preg_replace('/\.log$/i', $suffixinfilename.'.log', $tmp) : $tmp; } /** @@ -150,7 +151,9 @@ //throw new Exception('Failed to open log file '.basename($logfile)); print 'Failed to open log file '.($dolibarr_main_prod ?basename($logfile) : $logfile); } - } else { + } + else + { $logLevels = array( LOG_EMERG => 'EMERG', LOG_ALERT => 'ALERT', --- /tmp/dsg/dolibarr/htdocs/core/modules/syslog/github_mod_syslog_syslog.php +++ /tmp/dsg/dolibarr/htdocs/core/modules/syslog/client_mod_syslog_syslog.php @@ -7,7 +7,7 @@ */ class mod_syslog_syslog extends LogHandler implements LogHandlerInterface { - public $code = 'syslog'; + public $code = 'syslog'; /** * Return name of logger @@ -16,7 +16,7 @@ */ public function getName() { - return 'Syslogd'; + return 'Syslog'; } /** @@ -48,7 +48,7 @@ */ public function isActive() { - global $conf; + global $conf; // This function does not exists on some ISP (Ex: Free in France) if (!function_exists('openlog')) return 0; @@ -85,15 +85,17 @@ $errors = array(); - $facility = constant($conf->global->SYSLOG_FACILITY); - if ($facility) + $facility = constant($conf->global->SYSLOG_FACILITY); + if ($facility) { // Only LOG_USER supported on Windows if (!empty($_SERVER["WINDIR"])) $facility = constant('LOG_USER'); dol_syslog("admin/syslog: facility ".$facility); - } else { - $errors[] = $langs->trans("ErrorUnknownSyslogConstant", $facility); + } + else + { + $errors[] = $langs->trans("ErrorUnknownSyslogConstant", $facility); } return $errors; @@ -114,7 +116,8 @@ if (!empty($conf->global->SYSLOG_FACILITY)) // Example LOG_USER { $facility = constant($conf->global->SYSLOG_FACILITY); - } else $facility = constant('LOG_USER'); + } + else $facility = constant('LOG_USER'); // (int) is required to avoid error parameter 3 expected to be long openlog('dolibarr', LOG_PID | LOG_PERROR, (int) $facility);