Skip to content

Commit e6a3f0b

Browse files
committed
Update LaravelLogViewer.php
1 parent 8559d0f commit e6a3f0b

File tree

1 file changed

+19
-14
lines changed

1 file changed

+19
-14
lines changed

src/Rap2hpoutre/LaravelLogViewer/LaravelLogViewer.php

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -47,16 +47,7 @@ public static function all()
4747

4848
$pattern = '/\[\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}\].*/';
4949

50-
51-
if (!self::$file) {
52-
$log_file = self::getFiles();
53-
if(!count($log_file)) {
54-
return [];
55-
}
56-
self::$file = $log_file[0];
57-
}
58-
59-
$file = File::get(self::$file);
50+
$file = self::getCurrentFile();
6051

6152
preg_match_all($pattern, $file, $headings);
6253

@@ -96,8 +87,7 @@ public static function all()
9687
$level = strtoupper($ll);
9788

9889
preg_match('/^\[(\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2})\].*?\.' . $level . ': (.*?)( in .*?:[0-9]+)?$/', $h[$i], $current);
99-
100-
90+
10191
$log[] = array(
10292
'level' => $ll,
10393
'level_class' => $levels_classes[$ll],
@@ -113,8 +103,7 @@ public static function all()
113103
}
114104
}
115105

116-
$log = array_reverse($log);
117-
return $log;
106+
return array_reverse($log);
118107
}
119108

120109
/**
@@ -132,4 +121,20 @@ public static function getFiles($basename = false)
132121
}
133122
return $files;
134123
}
124+
125+
/**
126+
* @return array
127+
*/
128+
private static function getCurrentFile()
129+
{
130+
if (!self::$file) {
131+
$log_file = self::getFiles();
132+
if(!count($log_file)) {
133+
return [];
134+
}
135+
self::$file = $log_file[0];
136+
}
137+
138+
return File::get(self::$file);
139+
}
135140
}

0 commit comments

Comments
 (0)