Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/LogController.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public function tail($file, Request $request)
{
$offset = $request->get('offset');

$viewer = new LogViewer($file);
$viewer = new LogViewer($file.".log");
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since you already add .log in LogViewer::getFilePath(), this line may cause laravel.log.log issue


list($pos, $logs) = $viewer->tail($offset);

Expand Down
5 changes: 3 additions & 2 deletions src/LogViewer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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!');
Expand Down Expand Up @@ -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);
}
Expand Down