add line count

This commit is contained in:
Christopher 2022-07-14 23:07:50 +02:00
parent e5c792f90d
commit 22bf8365f1
2 changed files with 22 additions and 4 deletions

22
api.php
View File

@ -69,13 +69,31 @@
if(strtoupper($_REQUEST['METODE']) == "LOG")
{
$logOutput = $dockerClient->getContainerLogs($currentContainer['Id']);
$lines = 350;
if(isset($_REQUEST['LINES']))
{
if(trim($_REQUEST['LINES']) != "")
{
$lines = intval($_REQUEST['LINES']);
}
}
$logOutput = $dockerClient->getContainerLogs($currentContainer['Id'], $lines);
echo clean($logOutput);
}
if(strtoupper($_REQUEST['METODE']) == "HTMLLOG")
{
$logOutput = $dockerClient->getContainerLogs($currentContainer['Id']);
$lines = 350;
if(isset($_REQUEST['LINES']))
{
if(trim($_REQUEST['LINES']) != "")
{
$lines = intval($_REQUEST['LINES']);
}
}
$logOutput = $dockerClient->getContainerLogs($currentContainer['Id'], $lines);
echo html_entity_decode(clean($logOutput))."\n";
}

View File

@ -18,9 +18,9 @@
return json_decode($jsonRAWData, TRUE);
}
public function getContainerLogs($container){
public function getContainerLogs($container, $lines = 350){
curl_setopt($this->CurlClient, CURLOPT_POST, FALSE);
curl_setopt($this->CurlClient, CURLOPT_URL, "http:/v1.24/containers/".$container."/logs?stdout=1&tail=350");
curl_setopt($this->CurlClient, CURLOPT_URL, "http:/v1.24/containers/".$container."/logs?stdout=1&tail=".$lines);
$rawOutput = curl_exec($this->CurlClient);
return $rawOutput;