/** * {@inheritDoc} */ public function onAfterRun(CheckInterface $check, ResultInterface $result, $checkAlias = null) { switch (true) { case $result instanceof SuccessInterface: $this->output->write('OK'); break; case $result instanceof WarningInterface: $this->output->write('WARNING'); break; case $result instanceof SkipInterface: $this->output->write('SKIP'); break; default: $this->output->write('FAIL'); } $this->output->writeln(sprintf(' %s', $check->getLabel())); }
/** * {@inheritDoc} */ public function onAfterRun(CheckInterface $check, ResultInterface $result, $checkAlias = null) { switch (true) { case $result instanceof SuccessInterface: $this->output->write('<info>OK</info>'); break; case $result instanceof WarningInterface: $this->output->write('<comment>WARNING</comment>'); break; case $result instanceof SkipInterface: $this->output->write('<question>SKIP</question>'); break; default: $this->output->write('<error>FAIL</error>'); } $this->output->write(sprintf(' %s', $check->getLabel())); if ($message = $result->getMessage()) { $this->output->write(sprintf(': %s', $message)); } $this->output->writeln(''); }
/** * {@inheritDoc} */ public function onAfterRun(CheckInterface $check, ResultInterface $result, $checkAlias = null) { switch (true) { case $result instanceof SuccessInterface: $status = 0; $statusName = 'check_result_ok'; break; case $result instanceof WarningInterface: $status = 1; $statusName = 'check_result_warning'; $this->globalStatus = self::STATUS_KO; break; case $result instanceof SkipInterface: $status = 2; $statusName = 'check_result_skip'; break; default: $status = 3; $statusName = 'check_result_critical'; $this->globalStatus = self::STATUS_KO; } $this->results[] = array('checkName' => $check->getLabel(), 'message' => $result->getMessage(), 'status' => $status, 'status_name' => $statusName, 'service_id' => $checkAlias); }
/** * This method is called every time a Check has been performed. If this method * returns false, the Runner will not perform any additional checks and stop * its run. * * @param CheckInterface $check A Check instance that has just finished running * @param ResultInterface $result Result for that particular check instance * @param bool $alias The alias being targeted by the check * @return bool|void Return false to prevent from running additional Checks */ public function onAfterRun(CheckInterface $check, ResultInterface $result, $alias = null) { $descr = ' ' . $check->getLabel(); if ($message = $result->getMessage()) { $descr .= ': ' . $result->getMessage(); } if ($this->displayData && ($data = $result->getData())) { $descr .= PHP_EOL . str_repeat('-', $this->width - 7); $data = $result->getData(); if (is_object($data) && $data instanceof \Exception) { $descr .= PHP_EOL . get_class($data) . PHP_EOL . $data->getMessage() . $data->getTraceAsString(); } else { $descr .= PHP_EOL . @var_export($result->getData(), true); } $descr .= PHP_EOL . str_repeat('-', $this->width - 7); } // Draw status line if ($result instanceof Success) { $this->console->write(' OK ', Color::WHITE, Color::GREEN); $this->console->writeLine($this->strColPad($descr, $this->width - 7, ' '), Color::GREEN); } elseif ($result instanceof Failure) { $this->console->write(' FAIL ', Color::WHITE, Color::RED); $this->console->writeLine($this->strColPad($descr, $this->width - 7, ' '), Color::RED); } elseif ($result instanceof Warning) { $this->console->write(' WARN ', Color::NORMAL, Color::YELLOW); $this->console->writeLine($this->strColPad($descr, $this->width - 7, ' '), Color::YELLOW); } elseif ($result instanceof Skip) { $this->console->write(' SKIP ', Color::NORMAL, Color::YELLOW); $this->console->writeLine($this->strColPad($descr, $this->width - 7, ' '), Color::YELLOW); } else { $this->console->write(' ???? ', Color::NORMAL, Color::YELLOW); $this->console->writeLine($this->strColPad($descr, $this->width - 7, ' '), Color::YELLOW); } }