18 import(
'lib.pkp.classes.scheduledTask.ScheduledTaskHelper');
26 private $_processId =
null;
29 private $_executionLogFile;
41 $this->_processId = uniqid();
47 import(
'lib.pkp.classes.file.PrivateFileManager');
50 $scheduledTaskFilesPath = realpath($fileMgr->getBasePath()) . DIRECTORY_SEPARATOR . SCHEDULED_TASK_EXECUTION_LOG_DIR;
51 $this->_executionLogFile = $scheduledTaskFilesPath . DIRECTORY_SEPARATOR . str_replace(
' ',
'', $this->
getName()) .
52 '-' . $this->
getProcessId() .
'-' . date(
'Ymd') .
'.log';
53 if (!$fileMgr->fileExists($scheduledTaskFilesPath,
'dir')) {
54 $success = $fileMgr->mkdirtree($scheduledTaskFilesPath);
58 $this->_executionLogFile =
null;
72 return $this->_processId;
81 return $this->_helper;
90 return __(
'admin.scheduledTask');
100 $logFile = $this->_executionLogFile;
102 if (!$message)
return;
106 $log = $date .
'[' . __($type) .
'] ' . $message;
108 $log = $date . $message;
111 $fp = fopen($logFile,
'ab');
112 if (flock($fp, LOCK_EX)) {
113 fwrite($fp, $log . PHP_EOL);
144 $this->
addExecutionLogEntry(__(
'admin.scheduledTask.startTime'), SCHEDULED_TASK_MESSAGE_TYPE_NOTICE);
148 $this->
addExecutionLogEntry(__(
'admin.scheduledTask.stopTime'), SCHEDULED_TASK_MESSAGE_TYPE_NOTICE);
151 $helper->notifyExecutionResult($this->_processId, $this->
getName(), $result, $this->_executionLogFile);