/** * Stores log entries for given actions. * * @param string $component of the whole application * @param string $action the performed action to be logged */ protected function writeLogEntry($component, $action) { $entry = new \Roketi\Panel\Domain\Model\LogEntry(); $entry->setTimeStamp(new \DateTime()); $entry->setAction($action); $entry->setComponent($component); if ($this->doLogTheCurrentUser === TRUE) { $account = $this->context->getAccount(); $entry->setAccount($account); } else { $entry->unsetAccount(); } // fiddle out the IP of the client $requestHandler = $this->bootstrap->getActiveRequestHandler(); if ($requestHandler instanceof \TYPO3\Flow\Http\HttpRequestHandlerInterface) { $ip = $requestHandler->getHttpRequest()->getClientIPAddress(); } else { $ip = ''; } $entry->setRemoteIp($ip); $this->logEntryRepository->add($entry); $this->persistenceManager->persistAll(); }
/** * Render the last log entries */ public function indexAction() { $this->view->assign('entries', $this->logEntryRepository->findLatest()); }