diff --git a/htdocs/admin/system/perf.php b/htdocs/admin/system/perf.php index cc9ab7658db..fd586e24c95 100644 --- a/htdocs/admin/system/perf.php +++ b/htdocs/admin/system/perf.php @@ -82,14 +82,14 @@ print '
'; // Module log print '
'; print ''.$langs->trans("Syslog").': '; -$test = empty($conf->syslog->enabled); +$test = !isModEnabled('syslog'); if ($test) { print img_picto('', 'tick.png').' '.$langs->trans("NotInstalled").' '.$langs->trans("NotSlowedDownByThis").''; } else { - if ($conf->global->SYSLOG_LEVEL > LOG_NOTICE) { + if (getDolGlobalInt('SYSLOG_LEVEL') > LOG_NOTICE) { print img_picto('', 'warning').' '.$langs->trans("ModuleActivatedWithTooHighLogLevel", $langs->transnoentities("Syslog")); } else { - print img_picto('', 'tick.png').' '.$langs->trans("ModuleSyslogActivatedButLevelNotTooVerbose", $langs->transnoentities("Syslog"), $conf->global->SYSLOG_LEVEL); + print img_picto('', 'tick.png').' '.$langs->trans("ModuleSyslogActivatedButLevelNotTooVerbose", $langs->transnoentities("Syslog"), getDolGlobalInt('SYSLOG_LEVEL')); } //print ' '.$langs->trans("MoreInformation").' XDebug admin page'; } diff --git a/htdocs/admin/system/security.php b/htdocs/admin/system/security.php index 4515e4b7c2a..5775ea5404e 100644 --- a/htdocs/admin/system/security.php +++ b/htdocs/admin/system/security.php @@ -453,14 +453,14 @@ print load_fiche_titre($langs->trans("Modules"), '', 'folder'); // Module log print ''.$langs->trans("Syslog").': '; -$test = empty($conf->syslog->enabled); +$test = !isModEnabled('syslog'); if ($test) { print img_picto('', 'tick.png').' '.$langs->trans("NotInstalled").' - '.$langs->trans("NotRiskOfLeakWithThis"); } else { - if ($conf->global->SYSLOG_LEVEL > LOG_NOTICE) { + if (getDolGlobalInt('SYSLOG_LEVEL') > LOG_NOTICE) { print img_picto('', 'warning').' '.$langs->trans("ModuleActivatedWithTooHighLogLevel", $langs->transnoentities("Syslog")); } else { - print img_picto('', 'tick.png').' '.$langs->trans("ModuleSyslogActivatedButLevelNotTooVerbose", $langs->transnoentities("Syslog"), $conf->global->SYSLOG_LEVEL); + print img_picto('', 'tick.png').' '.$langs->trans("ModuleSyslogActivatedButLevelNotTooVerbose", $langs->transnoentities("Syslog"), getDolGlobalInt('SYSLOG_LEVEL')); } //print ' '.$langs->trans("MoreInformation").' XDebug admin page'; } diff --git a/htdocs/admin/tools/purge.php b/htdocs/admin/tools/purge.php index ee95fd7b44e..6c771abbd32 100644 --- a/htdocs/admin/tools/purge.php +++ b/htdocs/admin/tools/purge.php @@ -38,8 +38,8 @@ $nbsecondsold = GETPOSTINT('nbsecondsold'); // Define filelog to discard it from purge $filelog = ''; -if (!empty($conf->syslog->enabled)) { - $filelog = $conf->global->SYSLOG_FILE; +if (isModEnabled('syslog')) { + $filelog = getDolGlobalString('SYSLOG_FILE'); $filelog = preg_replace('/DOL_DATA_ROOT/i', DOL_DATA_ROOT, $filelog); } @@ -96,7 +96,7 @@ print ''; print '
'; -if (!empty($conf->syslog->enabled)) { +if (isModEnabled('syslog')) { print 'syslog = new stdClass(); $this->multicompany = new stdClass(); $this->expedition_bon = new stdClass(); $this->delivery_note = new stdClass(); @@ -212,7 +217,6 @@ class Conf // First level object // TODO Remove this part. - $this->syslog = new stdClass(); $this->expedition_bon = new stdClass(); $this->delivery_note = new stdClass(); $this->fournisseur = new stdClass(); @@ -1018,7 +1022,7 @@ class Conf } } - if (!empty($this->syslog->enabled)) { + if (isModEnabled('syslog')) { // We init log handlers if (!empty($this->global->SYSLOG_HANDLERS)) { $handlers = json_decode($this->global->SYSLOG_HANDLERS); diff --git a/htdocs/core/class/utils.class.php b/htdocs/core/class/utils.class.php index be91b49765b..f67702ca7c9 100644 --- a/htdocs/core/class/utils.class.php +++ b/htdocs/core/class/utils.class.php @@ -121,7 +121,7 @@ class Utils $filesarray = dol_dir_list($dolibarr_main_data_root, "files", 0, '.*\.log[\.0-9]*(\.gz)?$', 'install\.lock$', 'name', SORT_ASC, 0, 0, '', 1); } - if (!empty($conf->syslog->enabled)) { + if (isModEnabled('syslog')) { $filelog = $conf->global->SYSLOG_FILE; $filelog = preg_replace('/DOL_DATA_ROOT/i', DOL_DATA_ROOT, $filelog); diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index c6abf0e5b87..4345c936432 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -1641,7 +1641,7 @@ function dol_syslog($message, $level = LOG_INFO, $ident = 0, $suffixinfilename = global $conf, $user, $debugbar; // If syslog module enabled - if (empty($conf->syslog->enabled)) { + if (!isModEnabled('syslog')) { return; } diff --git a/htdocs/install/inc.php b/htdocs/install/inc.php index 970fd40261b..9dc12b18277 100644 --- a/htdocs/install/inc.php +++ b/htdocs/install/inc.php @@ -232,6 +232,9 @@ if ($islocked) { // Pages are locked // Force usage of log file for install and upgrades +if (!isset($conf->syslog) || !is_object($conf->syslog)) { + $conf->syslog = new stdClass(); +} $conf->syslog->enabled = 1; $conf->global->SYSLOG_LEVEL = constant('LOG_DEBUG'); if (!defined('SYSLOG_HANDLERS')) { @@ -341,6 +344,9 @@ function conf($dolibarr_main_document_root) $conf->db->dolibarr_main_db_cryptkey = $dolibarr_main_db_cryptkey; // Force usage of log file for install and upgrades + if (!isset($conf->syslog) || !is_object($conf->syslog)) { + $conf->syslog = new stdClass(); + } $conf->syslog->enabled = 1; $conf->global->SYSLOG_LEVEL = constant('LOG_DEBUG'); if (!defined('SYSLOG_HANDLERS')) { diff --git a/htdocs/support/inc.php b/htdocs/support/inc.php index 3f372e97c1e..1c8c4c5d7f8 100644 --- a/htdocs/support/inc.php +++ b/htdocs/support/inc.php @@ -39,7 +39,9 @@ $conf = new stdClass(); // instantiate $conf explicitely $conf->global = new stdClass(); $conf->file = new stdClass(); $conf->db = new stdClass(); -$conf->syslog = new stdClass(); +if (!isset($conf->syslog) || !is_object($conf->syslog)) { + $conf->syslog = new stdClass(); +} // Force $_REQUEST["logtohtml"] $_REQUEST["logtohtml"] = 1;