diff --git a/src/Pipeline/Pipe/ArrayPipe.php b/src/Pipeline/Pipe/ArrayPipe.php index d2fc519b..56003be4 100644 --- a/src/Pipeline/Pipe/ArrayPipe.php +++ b/src/Pipeline/Pipe/ArrayPipe.php @@ -89,7 +89,12 @@ public function run(State $state): Pipe */ protected function proceedStart(State $state): void { - $message = sprintf("Start '%s' pipeline with '%s' state.", \get_class($this), \get_class($state)); + $message = sprintf( + "Start '%s' pipeline with '%s' state.", + \get_class($this), + \get_class($state) + ); + $this->log(LogLevel::INFO, $message); } @@ -104,17 +109,24 @@ protected function proceedStart(State $state): void protected function proceedTask(State $state, Task $task): void { $taskName = $this->getTaskId($task); + $this->log( LogLevel::INFO, "Start '{$taskName}' task.", - ['task' => $taskName] + [ + 'task' => $taskName, + ] ); + $this->injectLoggerToTask($task); $task->run($state); + $this->log( LogLevel::INFO, "Complete '{$taskName}' task.", - ['task' => $taskName] + [ + 'task' => $taskName, + ] ); } @@ -130,12 +142,16 @@ protected function proceedTask(State $state, Task $task): void protected function proceedException(State $state, Task $task, Throwable $e): void { $taskName = $this->getTaskId($task); - $message = "Error while running {$taskName} task: {$e->getMessage()}"; + $message = "Error while running {$taskName} task."; - $this->log(LogLevel::ERROR, $message, [ - 'exception' => $e, - 'task' => $taskName, - ]); + $this->log( + LogLevel::ERROR, + $message, + [ + 'exception' => $e, + 'task' => $taskName, + ] + ); $this->proceedCleanup($state); @@ -195,7 +211,11 @@ protected function injectLoggerToTask(Task $task): void if ($task instanceof LoggableTask && $this->logger) { $task->injectLogger( $this->logger, - $this->createLoggerContext(['task' => $this->getTaskId($task)]) + $this->createLoggerContext( + [ + 'task' => $this->getTaskId($task), + ] + ) ); } }