From d641978d2dd5610f4610de450d023fe94a509301 Mon Sep 17 00:00:00 2001 From: Joseph Bassey Date: Fri, 6 Sep 2024 05:36:20 +0000 Subject: [PATCH] Modify log content in descending order before returning --- src/Pages/ViewLog.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Pages/ViewLog.php b/src/Pages/ViewLog.php index ec52ca8..3c9051e 100644 --- a/src/Pages/ViewLog.php +++ b/src/Pages/ViewLog.php @@ -46,7 +46,11 @@ public function read(): string return ''; } - return File::get($this->logFile); + $logContent = File::get($this->logFile); + + $logEntries = preg_split('/(?=\[\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}\])/', $logContent, -1, PREG_SPLIT_NO_EMPTY); + + return collect($logEntries)->reverse()->join("\n"); } public function clear(): void