diff --git a/api.php b/api.php index 17cf94b..ab1ca93 100644 --- a/api.php +++ b/api.php @@ -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"; } diff --git a/classen/docker.php b/classen/docker.php index edb65ce..4fc570b 100644 --- a/classen/docker.php +++ b/classen/docker.php @@ -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;