From ecd4d7748383f1b4f9497d579c2c392d83d67467 Mon Sep 17 00:00:00 2001 From: odain Date: Fri, 27 Feb 2026 16:53:10 +0100 Subject: [PATCH] enable logs + ci debugging --- .../php-unit-tests/unitary-tests/webservices/CronTest.php | 8 ++++---- webservices/cron.php | 2 ++ webservices/launch_cron_asynchronously.php | 8 +++++++- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/tests/php-unit-tests/unitary-tests/webservices/CronTest.php b/tests/php-unit-tests/unitary-tests/webservices/CronTest.php index f46a43abaf..984142da36 100644 --- a/tests/php-unit-tests/unitary-tests/webservices/CronTest.php +++ b/tests/php-unit-tests/unitary-tests/webservices/CronTest.php @@ -93,7 +93,7 @@ class CronTest extends ItopDataTestCase $this->AddLoginModeAndSaveConfiguration('form'); $this->CreateUserWithProfiles([self::$aURP_Profiles['REST Services User']]); - $sLogFileName = "crontest_".uniqid(); + $sLogFileName = "crontest_".uniqid().'.log'; $aPostFields = [ 'version' => '1.3', 'auth_user' => static::$sLogin, @@ -115,7 +115,7 @@ class CronTest extends ItopDataTestCase $this->AddLoginModeAndSaveConfiguration('basic'); $this->CreateUserWithProfiles([self::$aURP_Profiles['REST Services User']]); - $sLogFileName = "crontest_".uniqid(); + $sLogFileName = "crontest_".uniqid().'.log'; $aPostFields = [ 'version' => '1.3', 'verbose' => 1, @@ -140,7 +140,7 @@ class CronTest extends ItopDataTestCase $this->AddLoginModeAndSaveConfiguration('url'); $this->CreateUserWithProfiles([self::$aURP_Profiles['REST Services User']]); - $sLogFileName = "crontest_".uniqid(); + $sLogFileName = "crontest_".uniqid().'.log'; $aPostFields = [ 'version' => '1.3', 'verbose' => 1, @@ -177,7 +177,7 @@ class CronTest extends ItopDataTestCase { $this->CreateUserWithProfiles([self::$aURP_Profiles['Administrator']]); - $oLoginMode = new $sLoginModeClass; + $oLoginMode = new $sLoginModeClass(); $sUserLogin = $oLoginMode->GetUserLogin([static::$sLogin, static::$sPassword]); $this->assertEquals(static::$sLogin, $sUserLogin); } diff --git a/webservices/cron.php b/webservices/cron.php index 61c8d9475a..c0059205f9 100644 --- a/webservices/cron.php +++ b/webservices/cron.php @@ -36,6 +36,8 @@ if (file_exists(READONLY_MODE_FILE)) { require_once(APPROOT.'/application/application.inc.php'); require_once(APPROOT.'/core/background.inc.php'); +IssueLog::Enable(APPROOT.'log/error.log'); + $sConfigFile = APPCONF.ITOP_DEFAULT_ENV.'/'.ITOP_CONFIG_FILE; if (!file_exists($sConfigFile)) { echo "iTop is not yet installed. Exiting...\n"; diff --git a/webservices/launch_cron_asynchronously.php b/webservices/launch_cron_asynchronously.php index 88558aeefc..159e51cf90 100644 --- a/webservices/launch_cron_asynchronously.php +++ b/webservices/launch_cron_asynchronously.php @@ -31,6 +31,7 @@ function IsCronStartingLine(string $sLine): bool return preg_match('/^Starting: /', $sLine); } +IssueLog::Enable(APPROOT.'log/error.log'); try { $oCtx = new ContextTag(ContextTag::TAG_CRON); LoginWebPage::ResetSession(); @@ -65,6 +66,7 @@ try { } $sPHPExec = trim(\MetaModel::GetConfig()->Get('php_path')); + $aCronValues[] = "--auth_info=".escapeshellarg('XXXX'); $sCliForLogs = GetCliCommand($sPHPExec, $sLogFile, $aCronValues).PHP_EOL; IssueLog::Info("launch cron asynchronously/remotely", null, ['cli' => $sCliForLogs]); @@ -91,7 +93,11 @@ try { $oP->SetOutputDataOnly(true); $oP->Output(); } catch (Exception $e) { - \IssueLog::Error("Cannot run cron", null, ['msg' => $e->getMessage(), 'stack' => $e->getTraceAsString()]); + \IssueLog::Error('Cannot run cron', null, ['msg' => $e->getMessage(), 'stack' => $e->getTraceAsString()]); + \IssueLog::Error('Cannot run cron $_SERVER', null, $_SERVER); + \IssueLog::Error('Cannot run cron $_REQUEST', null, $_REQUEST); + \IssueLog::Error('Cannot run cron $_SESSION', null, $_SESSION); + http_response_code(500); $oP = new JsonPage(); $oP->add_header('Access-Control-Allow-Origin: *');