From 190adf2d4900938582846b1fd628f294fbf8c1a5 Mon Sep 17 00:00:00 2001 From: eldy <eldy@destailleur.fr> Date: Mon, 3 Oct 2011 17:19:39 +0200 Subject: [PATCH] New: Log module outputs can be setup with "or" rule (not only "xor"). --- ChangeLog | 1 + htdocs/admin/syslog.php | 147 +++++++++--------- htdocs/admin/tools/purge.php | 5 +- htdocs/core/class/conf.class.php | 2 +- .../filemanagerdol/connectors/php/config.php | 7 - htdocs/includes/dolibarr_changes.txt | 7 - htdocs/includes/modules/modSyslog.class.php | 2 +- htdocs/install/inc.php | 16 +- htdocs/langs/en_US/admin.lang | 10 +- htdocs/langs/fr_FR/admin.lang | 8 +- htdocs/lib/functions.lib.php | 45 +++--- 11 files changed, 118 insertions(+), 132 deletions(-) diff --git a/ChangeLog b/ChangeLog index e377db27912..a41c49c6a43 100644 --- a/ChangeLog +++ b/ChangeLog @@ -23,6 +23,7 @@ For users: For developers: - New: Add webservice to get or create a prodcut or service. +- New: Log module outputs can be setup with "or" rule (not only "xor"). - Qual: Removed no more used external libraries. - Qual: Cleaned a lot of dead code. - Qual: Parent templates classes were moved as abstract classes. diff --git a/htdocs/admin/syslog.php b/htdocs/admin/syslog.php index dc41e048ba6..149f537dabb 100644 --- a/htdocs/admin/syslog.php +++ b/htdocs/admin/syslog.php @@ -1,5 +1,5 @@ <?php -/* Copyright (C) 2005-2010 Laurent Destailleur <eldy@users.sourceforge.net> +/* Copyright (C) 2005-2011 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2005-2009 Regis Houssin <regis@dolibarr.fr> * Copyright (C) 2007 Rodolphe Quiedeville <rodolphe@quiedeville.org> * @@ -20,7 +20,7 @@ /** * \file htdocs/admin/syslog.php * \ingroup syslog - * \brief Setup page for syslog module + * \brief Setup page for logs module */ require("../main.inc.php"); @@ -31,97 +31,98 @@ if (!$user->admin) accessforbidden(); $langs->load("admin"); $langs->load("other"); +$error=0; $mesg=''; $action = GETPOST("action"); +$syslog_file_on=(defined('SYSLOG_FILE_ON') && constant('SYSLOG_FILE_ON'))?1:0; +$syslog_syslog_on=(defined('SYSLOG_SYSLOG_ON') && constant('SYSLOG_SYSLOG_ON'))?1:0; + /* * Actions */ -if ($action== 'setlevel') +// Set modes +if ($action == 'set') { - $level = GETPOST("level"); - $res = dolibarr_set_const($db,"SYSLOG_LEVEL",$level,'chaine',0,'',0); - dol_syslog("admin/syslog: level ".$level); + $db->begin(); - if (! $res > 0) $error++; - if (! $error) - { - $mesg = "<font class=\"ok\">".$langs->trans("SetupSaved")."</font>"; - } - else - { - $mesg = "<font class=\"error\">".$langs->trans("Error")."</font>"; - } -} + $res = dolibarr_del_const($db,"SYSLOG_FILE_ON",0); + $res = dolibarr_del_const($db,"SYSLOG_SYSLOG_ON",0); -if ($action == 'set') -{ - $optionlogoutput=GETPOST("optionlogoutput"); - $facility=GETPOST("facility"); - if ($optionlogoutput == "syslog") + if (! $error && GETPOST("filename")) { - if (defined($_POST["facility"])) + $filename=GETPOST("filename"); + $filelog=GETPOST("filename"); + $filelog=preg_replace('/DOL_DATA_ROOT/i',DOL_DATA_ROOT,$filelog); + $file=@fopen($filelog,"a+"); + if ($file) { - $db->begin; - // Only LOG_USER supported on Windows - if (! empty($_SERVER["WINDIR"])) $facility='LOG_USER'; + fclose($file); - $res = dolibarr_del_const($db,"SYSLOG_FILE",0); - if (! $res > 0) $error++; - $res = dolibarr_set_const($db,"SYSLOG_FACILITY",$facility,'chaine',0,'',0); + dol_syslog("admin/syslog: file ".$filename); + $res = dolibarr_set_const($db,"SYSLOG_FILE",$filename,'chaine',0,'',0); if (! $res > 0) $error++; - dol_syslog("admin/syslog: facility ".$facility); - if (! $error) - { - $db->commit(); - $mesg = "<font class=\"ok\">".$langs->trans("SetupSaved")."</font>"; - } - else - { - $db->rollback(); - $mesg = "<font class=\"error\">".$langs->trans("Error")."</font>"; - } + $syslog_file_on=GETPOST('SYSLOG_FILE_ON'); + if (! $error) $res = dolibarr_set_const($db,"SYSLOG_FILE_ON",$syslog_file_on,'chaine',0,'',0); } else { - $mesg = "<font class=\"error\">".$langs->trans("ErrorUnknownSyslogConstant",$facility)."</font>"; + $error++; + $mesg = "<font class=\"error\">".$langs->trans("ErrorFailedToOpenFile",$filename)."</font>"; } } - if ($optionlogoutput == "file") + if (! $error && GETPOST("facility")) { - $filename=GETPOST("filename"); - $filelog=GETPOST("filename"); - $filelog=preg_replace('/DOL_DATA_ROOT/i',DOL_DATA_ROOT,$filelog); - $file=fopen($filelog,"a+"); - if ($file) + $facility=GETPOST("facility"); + if (defined($_POST["facility"])) { - fclose($file); - $db->begin; - $res = dolibarr_del_const($db,"SYSLOG_FACILITY",0); - if (! $res > 0) $error++; - $res = dolibarr_set_const($db,"SYSLOG_FILE",$filename,'chaine',0,'',0); - if (! $res > 0) $error++; - dol_syslog("admin/syslog: file ".$filename); + // Only LOG_USER supported on Windows + if (! empty($_SERVER["WINDIR"])) $facility='LOG_USER'; + + dol_syslog("admin/syslog: facility ".$facility); + $res = dolibarr_set_const($db,"SYSLOG_FACILITY",$facility,'chaine',0,'',0); if (! $res > 0) $error++; - if (! $error) - { - $db->commit(); - $mesg = "<font class=\"ok\">".$langs->trans("SetupSaved")."</font>"; - } - else - { - $db->rollback(); - $mesg = "<font class=\"error\">".$langs->trans("Error")."</font>"; - } + $syslog_syslog_on=GETPOST('SYSLOG_SYSLOG_ON'); + if (! $error) $res = dolibarr_set_const($db,"SYSLOG_SYSLOG_ON",$syslog_syslog_on,'chaine',0,'',0); } else { - $mesg = "<font class=\"error\">".$langs->trans("ErrorFailedToOpenFile",$filename)."</font>"; + $error++; + $mesg = "<font class=\"error\">".$langs->trans("ErrorUnknownSyslogConstant",$facility)."</font>"; } } + + if (! $error) + { + $db->commit(); + $mesg = "<font class=\"ok\">".$langs->trans("SetupSaved")."</font>"; + } + else + { + $db->rollback(); + if (empty($mesg)) $mesg = "<font class=\"error\">".$langs->trans("Error")."</font>"; + } + } +// Set level +if ($action == 'setlevel') +{ + $level = GETPOST("level"); + $res = dolibarr_set_const($db,"SYSLOG_LEVEL",$level,'chaine',0,'',0); + dol_syslog("admin/syslog: level ".$level); + + if (! $res > 0) $error++; + if (! $error) + { + $mesg = "<font class=\"ok\">".$langs->trans("SetupSaved")."</font>"; + } + else + { + $mesg = "<font class=\"error\">".$langs->trans("Error")."</font>"; + } +} /* * View @@ -162,22 +163,28 @@ print '<td>'.$langs->trans("Type").'</td><td>'.$langs->trans("Value").'</td>'; print '<td align="right" colspan="2"><input type="submit" class="button" '.$option.' value="'.$langs->trans("Modify").'"></td>'; print "</tr>\n"; $var=true; + $var=!$var; -print '<tr '.$bc[$var].'><td width="140"><input '.$bc[$var].' type="radio" name="optionlogoutput" '.$option.' value="syslog" '.($syslogfacility?" checked":"").'> '.$langs->trans("SyslogSyslog").'</td>'; -print '<td colspan="3">'.$langs->trans("SyslogFacility").': <input type="text" class="flat" name="facility" '.$option.' value="'.$defaultsyslogfacility.'">'; -print ' '.img_info('Only LOG_USER supported on Windows'); +print '<tr '.$bc[$var].'><td width="140"><input '.$bc[$var].' type="checkbox" name="SYSLOG_FILE_ON" '.$option.' value="1" '.($syslog_file_on?" checked":"").'> '.$langs->trans("SyslogSimpleFile").'</td>'; +print '<td width="250" nowrap="nowrap">'.$langs->trans("SyslogFilename").': <input type="text" class="flat" name="filename" '.$option.' size="60" value="'.$defaultsyslogfile.'">'; +print '</td>'; +print "<td align=\"left\">".$html->textwithpicto('',$langs->trans("YouCanUseDOL_DATA_ROOT")); print '</td></tr>'; $var=!$var; -print '<tr '.$bc[$var].'><td width="140"><input '.$bc[$var].' type="radio" name="optionlogoutput" '.$option.' value="file" '.($syslogfile?" checked":"").'> '.$langs->trans("SyslogSimpleFile").'</td>'; -print '<td width="250" nowrap>'.$langs->trans("SyslogFilename").': <input type="text" class="flat" name="filename" '.$option.' size="60" value="'.$defaultsyslogfile.'">'; +print '<tr '.$bc[$var].'><td width="140"><input '.$bc[$var].' type="checkbox" name="SYSLOG_SYSLOG_ON" '.$option.' value="1" '.($syslog_syslog_on?" checked":"").'> '.$langs->trans("SyslogSyslog").'</td>'; +print '<td width="250" nowrap="nowrap">'.$langs->trans("SyslogFacility").': <input type="text" class="flat" name="facility" '.$option.' value="'.$defaultsyslogfacility.'">'; print '</td>'; -print "<td align=\"left\">".$html->textwithpicto('',$langs->trans("YouCanUseDOL_DATA_ROOT")); +print "<td align=\"left\">".$html->textwithpicto('','Only LOG_USER supported on Windows'); print '</td></tr>'; print "</table>\n"; print "</form>\n"; +print '<br>'; + +print_titre($langs->trans("SyslogLevel")); + // Level print '<form action="syslog.php" method="post">'; print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; diff --git a/htdocs/admin/tools/purge.php b/htdocs/admin/tools/purge.php index 2f229a00eee..de654b71832 100644 --- a/htdocs/admin/tools/purge.php +++ b/htdocs/admin/tools/purge.php @@ -25,8 +25,9 @@ include_once(DOL_DOCUMENT_ROOT.'/lib/files.lib.php'); $langs->load("admin"); -if (! $user->admin) -accessforbidden(); +$action=GETPOST('action'); + +if (! $user->admin) accessforbidden(); if ($_GET["msg"]) $message='<div class="error">'.$_GET["msg"].'</div>'; diff --git a/htdocs/core/class/conf.class.php b/htdocs/core/class/conf.class.php index 601d31dc199..9b21460fef5 100644 --- a/htdocs/core/class/conf.class.php +++ b/htdocs/core/class/conf.class.php @@ -121,7 +121,7 @@ class Conf $value=$objp->value; if ($key) { - if (! defined("$key")) define ("$key", $value); // In some cases, the constant might be already forced (Example: SYSLOG_FILE during install) + if (! defined("$key")) define ("$key", $value); // In some cases, the constant might be already forced (Example: SYSLOG_FILE_ON and SYSLOG_FILE during install) $this->global->$key=$value; if ($value && preg_match('/^MAIN_MODULE_/',$key)) diff --git a/htdocs/core/filemanagerdol/connectors/php/config.php b/htdocs/core/filemanagerdol/connectors/php/config.php index e638095379e..87dc899465c 100755 --- a/htdocs/core/filemanagerdol/connectors/php/config.php +++ b/htdocs/core/filemanagerdol/connectors/php/config.php @@ -36,13 +36,6 @@ $pos = strstr ($uri, '/'); // $pos contient alors url sans nom domaine if ($pos == '/') $pos = ''; // si $pos vaut /, on le met a '' define('DOL_URL_ROOT', $pos); -/* -$conf->syslog->enabled=1; -define('SYSLOG_FILE','c:/log/dolibarr/dolibarr.log'); -require_once("../../../../../../lib/functions.lib.php"); -dol_syslog("eee".$conf->fckeditor->dir_output); -*/ - // SECURITY: You must explicitly enable this "connector". (Set it to "true"). // WARNING: don't just set "$Config['Enabled'] = true ;", you must be sure that only // authenticated users can access this file or use some kind of session checking. diff --git a/htdocs/includes/dolibarr_changes.txt b/htdocs/includes/dolibarr_changes.txt index 9e0164ecdf8..d3caf076520 100644 --- a/htdocs/includes/dolibarr_changes.txt +++ b/htdocs/includes/dolibarr_changes.txt @@ -106,13 +106,6 @@ $pos = strstr ($uri, '/'); // $pos contient alors url sans nom domaine if ($pos == '/') $pos = ''; // si $pos vaut /, on le met a '' define('DOL_URL_ROOT', $pos); -/* -$conf->syslog->enabled=1; -define('SYSLOG_FILE','c:/log/dolibarr/dolibarr.log'); -require_once("../../../../../../lib/functions.lib.php"); -dol_syslog("eee".$conf->fckeditor->dir_output); -*/ - // SECURITY: You must explicitelly enable this "connector". (Set it to "true"). $Config['Enabled'] = true ; diff --git a/htdocs/includes/modules/modSyslog.class.php b/htdocs/includes/modules/modSyslog.class.php index 3ba470b055f..1a362f43079 100644 --- a/htdocs/includes/modules/modSyslog.class.php +++ b/htdocs/includes/modules/modSyslog.class.php @@ -28,7 +28,7 @@ include_once(DOL_DOCUMENT_ROOT ."/includes/modules/DolibarrModules.class.php"); /** * \class modSyslog - * \brief Classe de description et activation du module Syslog + * \brief Class to enable/disable module Logs */ class modSyslog extends DolibarrModules { diff --git a/htdocs/install/inc.php b/htdocs/install/inc.php index 062ce74d612..e2bfa1307c9 100644 --- a/htdocs/install/inc.php +++ b/htdocs/install/inc.php @@ -200,9 +200,10 @@ if (constant('DOL_DATA_ROOT') && file_exists($lockfile)) } -// Forcage du log pour les install et mises a jour +// Force usage of log file for install and upgrades $conf->syslog->enabled=1; $conf->global->SYSLOG_LEVEL=constant('LOG_DEBUG'); +if (! defined('SYSLOG_FILE_ON')) define('SYSLOG_FILE_ON',1); if (! defined('SYSLOG_FILE')) // To avoid warning on systems with constant already defined { if (@is_writable('/tmp')) define('SYSLOG_FILE','/tmp/dolibarr_install.log'); @@ -212,10 +213,7 @@ if (! defined('SYSLOG_FILE')) // To avoid warning on systems with constant alrea else if (@is_writable('../../')) define('SYSLOG_FILE','../../dolibarr_install.log'); // For others //print 'SYSLOG_FILE='.SYSLOG_FILE;exit; } -if (! defined('SYSLOG_FILE_NO_ERROR')) -{ - define('SYSLOG_FILE_NO_ERROR',1); -} +if (! defined('SYSLOG_FILE_NO_ERROR')) define('SYSLOG_FILE_NO_ERROR',1); // Removed magic_quotes if (function_exists('get_magic_quotes_gpc')) // magic_quotes_* removed in PHP6 @@ -285,9 +283,10 @@ function conf($dolibarr_main_document_root) if (empty($dolibarr_main_db_cryptkey)) $dolibarr_main_db_cryptkey=''; $conf->db->dolibarr_main_db_cryptkey = $dolibarr_main_db_cryptkey; - // Forcage du log pour les install et mises a jour + // Force usage of log file for install and upgrades $conf->syslog->enabled=1; $conf->global->SYSLOG_LEVEL=constant('LOG_DEBUG'); + if (! defined('SYSLOG_FILE_ON')) define('SYSLOG_FILE_ON',1); if (! defined('SYSLOG_FILE')) // To avoid warning on systems with constant already defined { if (@is_writable('/tmp')) define('SYSLOG_FILE','/tmp/dolibarr_install.log'); @@ -297,10 +296,7 @@ function conf($dolibarr_main_document_root) else if (@is_writable('../../')) define('SYSLOG_FILE','../../dolibarr_install.log'); // For others //print 'SYSLOG_FILE='.SYSLOG_FILE;exit; } - if (! defined('SYSLOG_FILE_NO_ERROR')) - { - define('SYSLOG_FILE_NO_ERROR',1); - } + if (! defined('SYSLOG_FILE_NO_ERROR')) define('SYSLOG_FILE_NO_ERROR',1); return 1; } diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index b25406bcfcf..2af977d0d17 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -338,8 +338,8 @@ Module30Name=Invoices Module30Desc=Invoices and credit note's management for customers. Invoice's management for suppliers Module40Name=Suppliers Module40Desc=Supplier's management and buying (orders and invoices) -Module42Name=Syslog -Module42Desc=Logging facilities (syslog) +Module42Name=Logs +Module42Desc=Logging facilities (file, syslog, ...) Module49Name=Editors Module49Desc=Editor's management Module50Name=Products @@ -1112,15 +1112,15 @@ UseEcoTaxeAbility=Support Eco-Taxe (WEEE) SetDefaultBarcodeTypeProducts=Default barcode type to use for products SetDefaultBarcodeTypeThirdParties=Default barcode type to use for third parties ##### Syslog ##### -SyslogSetup=Syslog module setup -SyslogOutput=Log output +SyslogSetup=Logs module setup +SyslogOutput=Logs outputs SyslogSyslog=Syslog SyslogFacility=Facility SyslogLevel=Level SyslogSimpleFile=File SyslogFilename=File name and path YouCanUseDOL_DATA_ROOT=You can use DOL_DATA_ROOT/dolibarr.log for a log file in Dolibarr "documents" directory. You can set a different path to store this file. -ErrorUnknownSyslogConstant=Constant %s is not a known syslog constant +ErrorUnknownSyslogConstant=Constant %s is not a known Syslog constant ##### Donations ##### DonationsSetup=Donation module setup DonationsReceiptModel=Template of donation receipt diff --git a/htdocs/langs/fr_FR/admin.lang b/htdocs/langs/fr_FR/admin.lang index af60ee973ac..7e9589e035d 100644 --- a/htdocs/langs/fr_FR/admin.lang +++ b/htdocs/langs/fr_FR/admin.lang @@ -128,7 +128,7 @@ SystemTools= Outils Système SystemToolsArea= Espace outils systèmes SystemToolsAreaDesc= Cet espace offre des fonctions d'administration diverses. Utilisez le menu pour choisir la fonctionnalité recherchée. PurgeAreaDesc= Cette page vous permet d'effacer tous les fichiers construits ou stockés par Dolibarr (fichiers temporaires ou tous les fichiers du répertoire <b>%s</b>). L'utilisation de cette fonction n'est pas nécessaire. Elle est fournie pour les utilisateurs qui hébergent Dolibarr chez un hébergeur qui n'offre pas les permissions de supprimer les fichiers sauvegardés par le serveur Web. -PurgeDeleteLogFile= Effacer le fichier log <b>%s</b> défini pour le module Syslog (pas de risque de perte de données) +PurgeDeleteLogFile= Effacer le fichier log <b>%s</b> défini pour le module 'Logs et traces' (pas de risque de perte de données) PurgeDeleteTemporaryFiles= Effacer tous les fichiers temporaires (pas de risque de perte de données) PurgeDeleteAllFilesInDocumentsDir= Effacer tous les fichiers du répertoire <b>%s</b>. Les fichiers temporaires mais aussi les fichiers dumps de sauvegardes de bases, les fichiers joints aux éléments (tiers, factures, ...) ou fichiers stockés dans le module GED seront irrémédiablement effacés. PurgeRunNow= Lancer la purge maintenant @@ -339,8 +339,8 @@ Module30Name= Factures et avoirs Module30Desc= Gestion des factures et avoirs clients. Gestion des factures fournisseurs Module40Name= Fournisseurs Module40Desc= Gestion des fournisseurs et achats (commandes et factures) -Module42Name= Syslog -Module42Desc= Utilisation de logs (syslog) +Module42Name= Logs et traces +Module42Desc= Génération de logs (fichiers, syslog, ...) Module49Name= Éditeurs Module49Desc= Gestion des éditeurs Module50Name= Produits @@ -1120,7 +1120,7 @@ UseEcoTaxeAbility= Prise en charge des éco-taxes (DEEE) SetDefaultBarcodeTypeProducts= Type de code-barres utilisé par défaut pour les produits SetDefaultBarcodeTypeThirdParties= Type de code-barres utilisé par défaut pour les tiers ##### Syslog ##### -SyslogSetup= Configuration du module Syslog +SyslogSetup= Configuration du module Logs et traces SyslogOutput= Sortie des log SyslogSyslog= Syslog SyslogFacility= Facility diff --git a/htdocs/lib/functions.lib.php b/htdocs/lib/functions.lib.php index bb6923f8697..7ee01dbf299 100644 --- a/htdocs/lib/functions.lib.php +++ b/htdocs/lib/functions.lib.php @@ -371,20 +371,22 @@ function dol_escape_htmltag($stringtoescape,$keepb=0) } /** - * Write log message in a file or to syslog process - * Pour fichier: fichier defined by SYSLOG_FILE - * Pour syslog: facility defined by SYSLOG_FACILITY + * Write log message into outputs. Possible outputs can be: + * A file if SYSLOG_FILE_ON defined: file name is then defined by SYSLOG_FILE + * Syslog if SYSLOG_SYSLOG_ON defined: facility is then defined by SYSLOG_FACILITY * Warning, les fonctions syslog sont buggues sous Windows et generent des * fautes de protection memoire. Pour resoudre, utiliser le loggage fichier, * au lieu du loggage syslog (configuration du module). - * Si SYSLOG_FILE_NO_ERROR defini, on ne gere pas erreur ecriture log + * Note: If SYSLOG_FILE_NO_ERROR defined, we never output error message when writing to log fails. + * * This function works only if syslog module is enabled. - * This must must not use any call to other function calling dol_syslog (avoid infinite loop). - * On Windows LOG_ERR=4, LOG_WARNING=5, LOG_NOTICE=LOG_INFO=6, LOG_DEBUG=6 si define_syslog_variables ou PHP 5.3+, 7 si dolibarr - * On Linux LOG_ERR=3, LOG_WARNING=4, LOG_INFO=6, LOG_DEBUG=7 + * This must not use any call to other function calling dol_syslog (avoid infinite loop). * - * @param string $message Line to log. Ne doit pas etre traduit si level = LOG_ERR - * @param int $level Log level + * @param string $message Line to log. Ne doit pas etre traduit si level = LOG_ERR + * @param int $level Log level + * On Windows LOG_ERR=4, LOG_WARNING=5, LOG_NOTICE=LOG_INFO=6, LOG_DEBUG=6 si define_syslog_variables ou PHP 5.3+, 7 si dolibarr + * On Linux LOG_ERR=3, LOG_WARNING=4, LOG_INFO=6, LOG_DEBUG=7 + * @return void */ function dol_syslog($message, $level=LOG_INFO) { @@ -421,8 +423,8 @@ function dol_syslog($message, $level=LOG_INFO) if (is_object($user) && $user->id) $login=$user->login; $message=sprintf("%-8s",$login)." ".$message; - // Check if log is to a file (SYSLOG_FILE defined) or to syslog - if (defined("SYSLOG_FILE") && SYSLOG_FILE) + // Check if log is to a file (SYSLOG_FILE_ON defined) + if (defined("SYSLOG_FILE_ON") && constant("SYSLOG_FILE_ON")) { $filelog=SYSLOG_FILE; $filelog=preg_replace('/DOL_DATA_ROOT/i',DOL_DATA_ROOT,$filelog); @@ -458,33 +460,26 @@ function dol_syslog($message, $level=LOG_INFO) } elseif (! defined("SYSLOG_FILE_NO_ERROR")) { - // Do not use call to functions that make call to dol_syslog, so no call to langs. + // Do not use here a call to functions that make call to dol_syslog so making call to langs. A simple print is enough. print "Error, failed to open file ".$filelog."\n"; } } - else + + // Check if log is to syslog (SYSLOG_SYSLOG_ON defined) + if (defined("SYSLOG_SYSLOG_ON") && constant("SYSLOG_SYSLOG_ON")) { if (function_exists('openlog')) // This function does not exists on some ISP (Ex: Free in France) { $facility = LOG_USER; - - if (defined("SYSLOG_FACILITY") && SYSLOG_FACILITY) + if (defined("SYSLOG_FACILITY") && constant("SYSLOG_FACILITY")) { // Exemple: SYSLOG_FACILITY vaut LOG_USER qui vaut 8. On a besoin de 8 dans $facility. $facility = constant("SYSLOG_FACILITY"); } openlog("dolibarr", LOG_PID | LOG_PERROR, (int) $facility); // (int) is required to avoid error parameter 3 expected to be long - - if (! $level) - { - syslog(LOG_ERR, $message); - } - else - { - syslog($level, $message); - } - + if (! $level) syslog(LOG_ERR, $message); + else syslog($level, $message); closelog(); } } -- GitLab