3
3
namespace Barryvdh \Debugbar \DataCollector ;
4
4
5
5
use DebugBar \DataCollector \MessagesCollector ;
6
+ use Illuminate \Support \Arr ;
6
7
use Psr \Log \LogLevel ;
7
8
use ReflectionClass ;
8
9
@@ -14,18 +15,14 @@ public function __construct($path = null, $name = 'logs')
14
15
{
15
16
parent ::__construct ($ name );
16
17
17
- $ path = $ path ?: $ this ->getLogsFile ();
18
- $ this ->getStorageLogs ($ path );
19
- }
20
-
21
- /**
22
- * Get the path to the logs file
23
- *
24
- * @return string
25
- */
26
- public function getLogsFile ()
27
- {
28
- return storage_path () . '/logs/laravel.log ' ;
18
+ $ paths = Arr::wrap ($ path ?: [
19
+ storage_path ('logs/laravel.log ' ),
20
+ storage_path ('logs/laravel- ' . date ('Y-m-d ' ) . '.log ' ), // for daily driver
21
+ ]);
22
+
23
+ foreach ($ paths as $ path ) {
24
+ $ this ->getStorageLogs ($ path );
25
+ }
29
26
}
30
27
31
28
/**
@@ -44,9 +41,16 @@ public function getStorageLogs($path)
44
41
45
42
//Load the latest lines, guessing about 15x the number of log entries (for stack traces etc)
46
43
$ file = implode ("" , $ this ->tailFile ($ path , $ this ->lines ));
44
+ $ basename = basename ($ path );
47
45
48
46
foreach ($ this ->getLogs ($ file ) as $ log ) {
49
- $ this ->addMessage ($ log ['header ' ] . $ log ['stack ' ], $ log ['level ' ], false );
47
+ $ this ->messages [] = [
48
+ 'message ' => $ log ['header ' ] . $ log ['stack ' ],
49
+ 'label ' => $ log ['level ' ],
50
+ 'time ' => substr ($ log ['header ' ], 1 , 19 ),
51
+ 'collector ' => $ basename ,
52
+ 'is_string ' => false ,
53
+ ];
50
54
}
51
55
}
52
56
@@ -115,11 +119,17 @@ public function getLogs($file)
115
119
}
116
120
}
117
121
118
- $ log = array_reverse ($ log );
119
-
120
122
return $ log ;
121
123
}
122
124
125
+ /**
126
+ * @return array
127
+ */
128
+ public function getMessages ()
129
+ {
130
+ return array_reverse (parent ::getMessages ());
131
+ }
132
+
123
133
/**
124
134
* Get the log levels from psr/log.
125
135
* Based on https://github.com/mikemand/logviewer/blob/master/src/Kmd/Logviewer/Logviewer.php by mikemand
0 commit comments