Add step type, step key, and updated timestamp to run logs
[MAILPOET-5568]
This commit is contained in:
@@ -5,6 +5,7 @@ namespace MailPoet\Automation\Engine\Control;
|
||||
use Exception;
|
||||
use MailPoet\Automation\Engine\Data\Automation;
|
||||
use MailPoet\Automation\Engine\Data\AutomationRun;
|
||||
use MailPoet\Automation\Engine\Data\AutomationRunLog;
|
||||
use MailPoet\Automation\Engine\Data\StepRunArgs;
|
||||
use MailPoet\Automation\Engine\Data\StepValidationArgs;
|
||||
use MailPoet\Automation\Engine\Data\SubjectEntry;
|
||||
@@ -86,7 +87,7 @@ class StepHandler {
|
||||
return;
|
||||
}
|
||||
|
||||
$logger = $this->stepRunLoggerFactory->createLogger($runId, $stepId);
|
||||
$logger = $this->stepRunLoggerFactory->createLogger($runId, $stepId, AutomationRunLog::TYPE_ACTION);
|
||||
$logger->logStart();
|
||||
try {
|
||||
$this->handleStep($runId, $stepId, $runNumber);
|
||||
|
@@ -25,16 +25,21 @@ class StepRunLogger {
|
||||
/** @var AutomationRunLog|null */
|
||||
private $log;
|
||||
|
||||
/** @var string */
|
||||
private $stepType;
|
||||
|
||||
public function __construct(
|
||||
AutomationRunLogStorage $automationRunLogStorage,
|
||||
Hooks $hooks,
|
||||
int $runId,
|
||||
string $stepId
|
||||
string $stepId,
|
||||
string $stepType
|
||||
) {
|
||||
$this->automationRunLogStorage = $automationRunLogStorage;
|
||||
$this->hooks = $hooks;
|
||||
$this->runId = $runId;
|
||||
$this->stepId = $stepId;
|
||||
$this->stepType = $stepType;
|
||||
}
|
||||
|
||||
public function logStart(): void {
|
||||
@@ -44,7 +49,7 @@ class StepRunLogger {
|
||||
public function logSuccess(): void {
|
||||
$log = $this->getLog();
|
||||
$log->setStatus(AutomationRunLog::STATUS_COMPLETE);
|
||||
$log->setCompletedAt(new DateTimeImmutable());
|
||||
$log->setUpdatedAt(new DateTimeImmutable());
|
||||
$this->triggerAfterRunHook($log);
|
||||
$this->automationRunLogStorage->updateAutomationRunLog($log);
|
||||
}
|
||||
@@ -53,7 +58,7 @@ class StepRunLogger {
|
||||
$log = $this->getLog();
|
||||
$log->setStatus(AutomationRunLog::STATUS_FAILED);
|
||||
$log->setError($error);
|
||||
$log->setCompletedAt(new DateTimeImmutable());
|
||||
$log->setUpdatedAt(new DateTimeImmutable());
|
||||
$this->triggerAfterRunHook($log);
|
||||
$this->automationRunLogStorage->updateAutomationRunLog($log);
|
||||
}
|
||||
@@ -64,7 +69,7 @@ class StepRunLogger {
|
||||
}
|
||||
|
||||
if (!$this->log) {
|
||||
$log = new AutomationRunLog($this->runId, $this->stepId);
|
||||
$log = new AutomationRunLog($this->runId, $this->stepId, $this->stepType);
|
||||
$id = $this->automationRunLogStorage->createAutomationRunLog($log);
|
||||
$this->log = $this->automationRunLogStorage->getAutomationRunLog($id);
|
||||
}
|
||||
|
@@ -20,7 +20,7 @@ class StepRunLoggerFactory {
|
||||
$this->hooks = $hooks;
|
||||
}
|
||||
|
||||
public function createLogger(int $runId, string $stepId): StepRunLogger {
|
||||
return new StepRunLogger($this->automationRunLogStorage, $this->hooks, $runId, $stepId);
|
||||
public function createLogger(int $runId, string $stepId, string $stepType): StepRunLogger {
|
||||
return new StepRunLogger($this->automationRunLogStorage, $this->hooks, $runId, $stepId, $stepType);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user