Skip to content

Commit

Permalink
fix to big error.log file
Browse files Browse the repository at this point in the history
  • Loading branch information
JavanXD committed Mar 11, 2021
1 parent f9129d9 commit c9d0f47
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion backend/log.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@
// text
header('Content-type:text/plain;charset=utf-8');

function getLastLines($string, $n = 1) {
$lines = explode("\n", $string);
$lines = array_slice($lines, -$n);
return implode("\n", $lines);
}

// delete log
if (isset($_GET['delete']))
{
Expand All @@ -14,7 +20,8 @@

// read log
if (file_exists($logFile)) {
echo file_get_contents($logFile);
$logFile_content = file_get_contents($logFile);
echo getLastLines($logFile_content, 500);
} else {
echo "NOFILE";
}

0 comments on commit c9d0f47

Please sign in to comment.