From afd9787e997e08670f481f1a3ba01c7dd70d5967 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 3 Jun 2022 11:52:39 +0200 Subject: [PATCH] Help debug cron --- htdocs/core/lib/functions.lib.php | 5 +++++ htdocs/public/cron/cron_run_jobs_by_url.php | 6 ++++++ scripts/cron/cron_run_jobs.php | 7 ++++++- 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 85ac02e8b10..84d3445442e 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -1563,6 +1563,11 @@ function dol_syslog($message, $level = LOG_INFO, $ident = 0, $suffixinfilename = } } + // Check if we have a forced suffix + if (defined('USESUFFIXINLOG')) { + $suffixinfilename .= constant('USESUFFIXINLOG'); + } + if ($ident < 0) { foreach ($conf->loghandlers as $loghandlerinstance) { $loghandlerinstance->setIdent($ident); diff --git a/htdocs/public/cron/cron_run_jobs_by_url.php b/htdocs/public/cron/cron_run_jobs_by_url.php index 9369a9d78a7..8aa910a2d4f 100644 --- a/htdocs/public/cron/cron_run_jobs_by_url.php +++ b/htdocs/public/cron/cron_run_jobs_by_url.php @@ -23,6 +23,7 @@ * \ingroup cron * \brief Execute pendings jobs */ + if (!defined('NOTOKENRENEWAL')) { define('NOTOKENRENEWAL', '1'); // Disables token renewal } @@ -42,6 +43,11 @@ if (!defined('NOIPCHECK')) { define('NOIPCHECK', '1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip } +// So log file will have a suffix +if (!defined('USESUFFIXINLOG')) { + define('USESUFFIXINLOG', '_cron'); +} + // For MultiCompany module. // Do not use GETPOST here, function is not defined and define must be done before including main.inc.php $entity = (!empty($_GET['entity']) ? (int) $_GET['entity'] : (!empty($_POST['entity']) ? (int) $_POST['entity'] : 1)); diff --git a/scripts/cron/cron_run_jobs.php b/scripts/cron/cron_run_jobs.php index 647b1405d71..25ea4b4d415 100755 --- a/scripts/cron/cron_run_jobs.php +++ b/scripts/cron/cron_run_jobs.php @@ -22,7 +22,7 @@ /** * \file scripts/cron/cron_run_jobs.php * \ingroup cron - * \brief Execute pendings jobs + * \brief Execute pendings jobs from command line */ if (!defined('NOTOKENRENEWAL')) { @@ -44,6 +44,11 @@ if (!defined('NOSESSION')) { define('NOSESSION', '1'); } +// So log file will have a suffix +if (!defined('USESUFFIXINLOG')) { + define('USESUFFIXINLOG', '_cron'); +} + $sapi_type = php_sapi_name(); $script_file = basename(__FILE__); $path = __DIR__.'/';