getTask(); if ($task instanceof VerbosityThresholdInterface && !$task->verbosityMeetsThreshold()) { return; } if (!$result->wasSuccessful()) { return $this->printError($result); } else { return $this->printSuccess($result); } } /** * Log that we are about to abort due to an error being encountered * in 'stop on fail' mode. * * @param \Robo\Result $result */ public function printStopOnFail($result) { $this->printMessage(LogLevel::NOTICE, 'Stopping on fail. Exiting....'); $this->printMessage(LogLevel::ERROR, 'Exit Code: {code}', ['code' => $result->getExitCode()]); } /** * Log the result of a Robo task that returned an error. * * @param \Robo\Result $result * * @return bool */ protected function printError(Result $result) { $task = $result->getTask(); $context = $result->getContext() + ['timer-label' => 'Time', '_style' => []]; $context['_style']['message'] = ''; $printOutput = true; if ($task instanceof PrintedInterface) { $printOutput = !$task->getPrinted(); } if ($printOutput) { $this->printMessage(LogLevel::ERROR, "{message}", $context); } $this->printMessage(LogLevel::ERROR, 'Exit code {code}', $context); return true; } /** * Log the result of a Robo task that was successful. * * @param \Robo\Result $result * * @return bool */ protected function printSuccess(Result $result) { $task = $result->getTask(); $context = $result->getContext() + ['timer-label' => 'in']; $time = $result->getExecutionTime(); if ($time) { $this->printMessage(ConsoleLogLevel::SUCCESS, 'Done', $context); } return false; } /** * @param string $level * @param string $message * @param array $context */ protected function printMessage($level, $message, $context = []) { $inProgress = $this->hideProgressIndicator(); $this->logger->log($level, $message, $context); if ($inProgress) { $this->restoreProgressIndicator($inProgress); } } }