Log step key data
[MAILPOET-5568]
This commit is contained in:
@ -90,7 +90,7 @@ class StepHandler {
|
|||||||
$logger = $this->stepRunLoggerFactory->createLogger($runId, $stepId, AutomationRunLog::TYPE_ACTION);
|
$logger = $this->stepRunLoggerFactory->createLogger($runId, $stepId, AutomationRunLog::TYPE_ACTION);
|
||||||
$logger->logStart();
|
$logger->logStart();
|
||||||
try {
|
try {
|
||||||
$this->handleStep($runId, $stepId, $runNumber);
|
$this->handleStep($runId, $stepId, $runNumber, $logger);
|
||||||
$logger->logSuccess();
|
$logger->logSuccess();
|
||||||
} catch (Throwable $e) {
|
} catch (Throwable $e) {
|
||||||
$status = $e instanceof InvalidStateException && $e->getErrorCode() === 'mailpoet_automation_not_active'
|
$status = $e instanceof InvalidStateException && $e->getErrorCode() === 'mailpoet_automation_not_active'
|
||||||
@ -110,7 +110,7 @@ class StepHandler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private function handleStep(int $runId, string $stepId, int $runNumber): void {
|
private function handleStep(int $runId, string $stepId, int $runNumber, StepRunLogger $logger): void {
|
||||||
$automationRun = $this->automationRunStorage->getAutomationRun($runId);
|
$automationRun = $this->automationRunStorage->getAutomationRun($runId);
|
||||||
if (!$automationRun) {
|
if (!$automationRun) {
|
||||||
throw Exceptions::automationRunNotFound($runId);
|
throw Exceptions::automationRunNotFound($runId);
|
||||||
@ -134,6 +134,8 @@ class StepHandler {
|
|||||||
throw Exceptions::automationStepNotFound($stepId);
|
throw Exceptions::automationStepNotFound($stepId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$logger->logStepData($stepData);
|
||||||
|
|
||||||
$step = $this->registry->getStep($stepData->getKey());
|
$step = $this->registry->getStep($stepData->getKey());
|
||||||
if (!$step instanceof Action) {
|
if (!$step instanceof Action) {
|
||||||
throw new InvalidStateException();
|
throw new InvalidStateException();
|
||||||
|
@ -4,6 +4,7 @@ namespace MailPoet\Automation\Engine\Control;
|
|||||||
|
|
||||||
use DateTimeImmutable;
|
use DateTimeImmutable;
|
||||||
use MailPoet\Automation\Engine\Data\AutomationRunLog;
|
use MailPoet\Automation\Engine\Data\AutomationRunLog;
|
||||||
|
use MailPoet\Automation\Engine\Data\Step;
|
||||||
use MailPoet\Automation\Engine\Hooks;
|
use MailPoet\Automation\Engine\Hooks;
|
||||||
use MailPoet\Automation\Engine\Storage\AutomationRunLogStorage;
|
use MailPoet\Automation\Engine\Storage\AutomationRunLogStorage;
|
||||||
use MailPoet\InvalidStateException;
|
use MailPoet\InvalidStateException;
|
||||||
@ -46,6 +47,12 @@ class StepRunLogger {
|
|||||||
$this->getLog();
|
$this->getLog();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function logStepData(Step $step): void {
|
||||||
|
$log = $this->getLog();
|
||||||
|
$log->setStepKey($step->getKey());
|
||||||
|
$this->automationRunLogStorage->updateAutomationRunLog($log);
|
||||||
|
}
|
||||||
|
|
||||||
public function logSuccess(): void {
|
public function logSuccess(): void {
|
||||||
$log = $this->getLog();
|
$log = $this->getLog();
|
||||||
$log->setStatus(AutomationRunLog::STATUS_COMPLETE);
|
$log->setStatus(AutomationRunLog::STATUS_COMPLETE);
|
||||||
|
Reference in New Issue
Block a user