Add run number to logs

[MAILPOET-5568]
This commit is contained in:
Jan Jakes
2023-09-05 15:34:06 +02:00
committed by Aschepikov
parent ef97e4d05a
commit 864cc2b01d
5 changed files with 40 additions and 6 deletions

View File

@@ -29,18 +29,23 @@ class StepRunLogger {
/** @var string */
private $stepType;
/** @var int */
private $runNumber;
public function __construct(
AutomationRunLogStorage $automationRunLogStorage,
Hooks $hooks,
int $runId,
string $stepId,
string $stepType
string $stepType,
int $runNumber
) {
$this->automationRunLogStorage = $automationRunLogStorage;
$this->hooks = $hooks;
$this->runId = $runId;
$this->stepId = $stepId;
$this->stepType = $stepType;
$this->runNumber = $runNumber;
}
public function logStart(): void {
@@ -53,6 +58,13 @@ class StepRunLogger {
$this->automationRunLogStorage->updateAutomationRunLog($log);
}
public function logProgress(): void {
$log = $this->getLog();
$log->setStatus(AutomationRunLog::STATUS_RUNNING);
$log->setUpdatedAt(new DateTimeImmutable());
$this->automationRunLogStorage->updateAutomationRunLog($log);
}
public function logSuccess(): void {
$log = $this->getLog();
$log->setStatus(AutomationRunLog::STATUS_COMPLETE);
@@ -77,6 +89,7 @@ class StepRunLogger {
if (!$this->log) {
$log = new AutomationRunLog($this->runId, $this->stepId, $this->stepType);
$log->setRunNumber($this->runNumber);
$id = $this->automationRunLogStorage->createAutomationRunLog($log);
$this->log = $this->automationRunLogStorage->getAutomationRunLog($id);
}
@@ -84,6 +97,8 @@ class StepRunLogger {
if (!$this->log) {
throw new InvalidStateException('Failed to create automation run log');
}
$this->log->setRunNumber($this->runNumber);
return $this->log;
}