public function testGet() { $this->webLogger->log('Message1' . PHP_EOL); $this->webLogger->log('Message2'); $expected = ['<span class="text-info">Message1', '</span><br><span class="text-info">Message2</span><br>']; $this->assertEquals($expected, $this->webLogger->get()); }
/** * Checks progress of installation * * @return JsonModel */ public function progressAction() { $percent = 0; $success = false; $contents = []; $json = new JsonModel(); // Depending upon the install environment and network latency, there is a possibility that // "progress" check request may arrive before the Install POST request. In that case // "install.log" file may not be created yet. Check the "install.log" is created before // trying to read from it. if (!$this->log->logfileExists()) { return $json->setVariables(['progress' => $percent, 'success' => true, 'console' => $contents]); } try { $progress = $this->progressFactory->createFromLog($this->log); $percent = sprintf('%d', $progress->getRatio() * 100); $success = true; $contents = $this->log->get(); if ($this->sampleDataState->hasError()) { $json->setVariable('isSampleDataError', true); } } catch (\Exception $e) { $contents = [(string) $e]; } return $json->setVariables(['progress' => $percent, 'success' => $success, 'console' => $contents]); }
/** * Creates a progress indicator from log contents * * @param WebLogger $logger * @return Progress */ public function createFromLog(WebLogger $logger) { $total = 1; $current = 0; $contents = implode('', $logger->get()); if (preg_match_all(Installer::PROGRESS_LOG_REGEX, $contents, $matches, PREG_SET_ORDER)) { $last = array_pop($matches); list(, $current, $total) = $last; } $progress = new Progress($total, $current); return $progress; }
/** * Checks progress of installation * * @return JsonModel */ public function progressAction() { $percent = 0; $success = false; try { $progress = $this->progressFactory->createFromLog($this->log); $percent = sprintf('%d', $progress->getRatio() * 100); $success = true; $contents = $this->log->get(); } catch (\Exception $e) { $contents = [(string) $e]; } return new JsonModel(['progress' => $percent, 'success' => $success, 'console' => $contents]); }
/** * Checks progress of installation * * @return JsonModel */ public function progressAction() { $percent = 0; $success = false; $json = new JsonModel(); try { $progress = $this->progressFactory->createFromLog($this->log); $percent = sprintf('%d', $progress->getRatio() * 100); $success = true; $contents = $this->log->get(); } catch (\Exception $e) { $contents = [(string)$e]; if ($e instanceof \Magento\Setup\SampleDataException) { $json->setVariable('isSampleDataError', true); } } return $json->setVariables(['progress' => $percent, 'success' => $success, 'console' => $contents]); }