pohja/LastLog.php

19 lines
610 B
PHP
Raw Permalink Normal View History

2024-02-03 14:08:03 +01:00
<?php
require_once("Settings.php");
$limit = 100;
if (isset($argv[1]) && is_numeric($argv[1])) {
$limit = $argv[1];
}
$db = new Database();
$stmt = $db::$handle->prepare("SELECT * FROM (SELECT * FROM `logs` ORDER BY datetime(`created`) DESC, `id` DESC LIMIT " . $limit . ") ORDER BY `created` ASC, `id` ASC");
$result = $stmt->execute();
while ($row = $result->fetchArray(SQLITE3_ASSOC)) {
$levelColor = Logger::getColor($row["level"]);
echo "\033[0;37m[" . $row["created"] . "] " . $levelColor . $row["level"] . "\033[0;37m: " . $row["message"] . "\033[0m" . PHP_EOL;
}
$db->close();