diff --git a/src/LogController.php b/src/LogController.php index 3f6e925..5bffc9b 100644 --- a/src/LogController.php +++ b/src/LogController.php @@ -40,7 +40,7 @@ public function tail($file, Request $request) { $offset = $request->get('offset'); - $viewer = new LogViewer($file); + $viewer = new LogViewer($file.".log"); list($pos, $logs) = $viewer->tail($offset); diff --git a/src/LogViewer.php b/src/LogViewer.php index 96eef0c..b6b010d 100644 --- a/src/LogViewer.php +++ b/src/LogViewer.php @@ -72,7 +72,7 @@ public function __construct($file = null) public function getFilePath() { if (!$this->filePath) { - $path = sprintf(storage_path('logs/%s'), $this->file); + $path = sprintf(storage_path('logs/%s').".log", $this->file); if (!file_exists($path)) { throw new \Exception('log not exists!'); @@ -103,11 +103,12 @@ public function getFilesize() */ public function getLogFiles($count = 20) { - $files = glob(storage_path('logs/*')); + $files = glob(storage_path('logs/*.log')); $files = array_combine($files, array_map('filemtime', $files)); arsort($files); $files = array_map('basename', array_keys($files)); + $files = array_map(function($x){ return str_replace(".log", "", $x);}, $files); return array_slice($files, 0, $count); }