Reverse order and multiple log files handler

This commit is contained in:
2023-02-15 17:45:23 -03:00
parent 110f37e4f4
commit c29eece81c
16 changed files with 494 additions and 101 deletions

View File

@ -22,4 +22,21 @@ class Logs
}
return $view->render($response, 'logs.show', compact('log', 'levels'));
}
public function getMore(ServerRequestInterface $request, ResponseInterface $response, View $view, Service $service, string $log_file, int $start = 0, int $amount = 100): ResponseInterface
{
$log = $service->get($log_file);
$logs = [];
foreach ($log->getLogs($start, $amount) as $l) {
$logs []= $l;
}
$logs = array_reverse($logs);
$total = $log->getTotal();
$response->getBody()->write(\Safe\json_encode([
'total' => $total,
'logs' => $logs
]));
return $response->withStatus(200)
->withHeader('Content-Type', 'application/json');
}
}