From d4cbeaf7072c205d26ee3fdc8032730b77b0310b Mon Sep 17 00:00:00 2001 From: Bozana Bokan Date: Wed, 12 Jun 2024 14:35:46 +0200 Subject: [PATCH] pkp/pkp-lib#9979 use class name for scheduled task log file name --- classes/scheduledTask/ScheduledTask.inc.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/classes/scheduledTask/ScheduledTask.inc.php b/classes/scheduledTask/ScheduledTask.inc.php index f81d7502341..10c4fe27997 100644 --- a/classes/scheduledTask/ScheduledTask.inc.php +++ b/classes/scheduledTask/ScheduledTask.inc.php @@ -42,13 +42,14 @@ function __construct($args = array()) { // Ensure common locale keys are available AppLocale::requireComponents(LOCALE_COMPONENT_PKP_ADMIN, LOCALE_COMPONENT_APP_ADMIN, LOCALE_COMPONENT_PKP_COMMON); - + // Check the scheduled task execution log folder. import('lib.pkp.classes.file.PrivateFileManager'); $fileMgr = new PrivateFileManager(); $scheduledTaskFilesPath = realpath($fileMgr->getBasePath()) . DIRECTORY_SEPARATOR . SCHEDULED_TASK_EXECUTION_LOG_DIR; - $this->_executionLogFile = $scheduledTaskFilesPath . DIRECTORY_SEPARATOR . str_replace(' ', '', $this->getName()) . + $classNameParts = explode('\\', get_class($this)); // Separate namespace info from class name + $this->_executionLogFile = $scheduledTaskFilesPath . DIRECTORY_SEPARATOR . end($classNameParts) . '-' . $this->getProcessId() . '-' . date('Ymd') . '.log'; if (!$fileMgr->fileExists($scheduledTaskFilesPath, 'dir')) { $success = $fileMgr->mkdirtree($scheduledTaskFilesPath); @@ -115,7 +116,7 @@ function addExecutionLogEntry($message, $type = null) { } else { fatalError("Couldn't lock the file."); } - fclose($fp); + fclose($fp); }