@@ -54,11 +54,18 @@ public function __construct()
5454 */
5555 public function setFolder ($ folder )
5656 {
57- $ logsPath = $ this ->storage_path . '/ ' . $ folder ;
58-
59- if (app ('files ' )->exists ($ logsPath )) {
57+ if (app ('files ' )->exists ($ folder )) {
6058 $ this ->folder = $ folder ;
6159 }
60+ if (is_array ($ this ->storage_path )){
61+ foreach ($ this ->storage_path as $ value ) {
62+ $ logsPath = $ value . '/ ' . $ folder ;
63+ if (app ('files ' )->exists ($ logsPath )) {
64+ $ this ->folder = $ folder ;
65+ break ;
66+ }
67+ }
68+ }
6269 }
6370
6471 /**
@@ -81,20 +88,27 @@ public function setFile($file)
8188 */
8289 public function pathToLogFile ($ file )
8390 {
84- $ logsPath = $ this ->storage_path ;
85- $ logsPath .= ($ this ->folder ) ? '/ ' . $ this ->folder : '' ;
8691
8792 if (app ('files ' )->exists ($ file )) { // try the absolute path
8893 return $ file ;
8994 }
95+ if (is_array ($ this ->storage_path )) {
96+ foreach ($ this ->storage_path as $ folder ) {
97+ if (app ('files ' )->exists ($ folder . '/ ' . $ file )) { // try the absolute path
98+ $ file = $ folder . '/ ' . $ file ;
99+ break ;
100+ }
101+ }
102+ return $ file ;
103+ }
90104
105+ $ logsPath = $ this ->storage_path ;
106+ $ logsPath .= ($ this ->folder ) ? '/ ' . $ this ->folder : '' ;
91107 $ file = $ logsPath . '/ ' . $ file ;
92-
93108 // check if requested file is really in the logs directory
94109 if (dirname ($ file ) !== $ logsPath ) {
95110 throw new \Exception ('No such log file ' );
96111 }
97-
98112 return $ file ;
99113 }
100114
@@ -129,7 +143,9 @@ public function all()
129143 $ this ->file = $ log_file [0 ];
130144 }
131145
132- if (app ('files ' )->size ($ this ->file ) > self ::MAX_FILE_SIZE ) return null ;
146+ if (app ('files ' )->size ($ this ->file ) > self ::MAX_FILE_SIZE ) {
147+ return null ;
148+ }
133149
134150 $ file = app ('files ' )->get ($ this ->file );
135151
@@ -150,12 +166,15 @@ public function all()
150166 foreach ($ this ->level ->all () as $ level ) {
151167 if (strpos (strtolower ($ h [$ i ]), '. ' . $ level ) || strpos (strtolower ($ h [$ i ]), $ level . ': ' )) {
152168
153- preg_match ($ this ->pattern ->getPattern ('current_log ' ,0 ) . $ level . $ this ->pattern ->getPattern ('current_log ' ,1 ), $ h [$ i ], $ current );
154- if (!isset ($ current [4 ])) continue ;
169+ preg_match ($ this ->pattern ->getPattern ('current_log ' , 0 ) . $ level . $ this ->pattern ->getPattern ('current_log ' , 1 ), $ h [$ i ], $ current );
170+ if (!isset ($ current [4 ])) {
171+ continue ;
172+ }
155173
156174 $ log [] = array (
157175 'context ' => $ current [3 ],
158176 'level ' => $ level ,
177+ 'folder ' => $ this ->folder ,
159178 'level_class ' => $ this ->level ->cssClass ($ level ),
160179 'level_img ' => $ this ->level ->img ($ level ),
161180 'date ' => $ current [1 ],
@@ -177,6 +196,7 @@ public function all()
177196 $ log [] = [
178197 'context ' => '' ,
179198 'level ' => '' ,
199+ 'folder ' => '' ,
180200 'level_class ' => '' ,
181201 'level_img ' => '' ,
182202 'date ' => $ key + 1 ,
@@ -195,7 +215,16 @@ public function all()
195215 */
196216 public function getFolders ()
197217 {
198- $ folders = glob ($ this ->storage_path .'/* ' , GLOB_ONLYDIR );
218+ $ folders = glob ($ this ->storage_path . '/* ' , GLOB_ONLYDIR );
219+ if (is_array ($ this ->storage_path )) {
220+ foreach ($ this ->storage_path as $ value ) {
221+ $ folders = array_merge (
222+ $ folders ,
223+ glob ($ value . '/* ' , GLOB_ONLYDIR )
224+ );
225+ }
226+ }
227+
199228 if (is_array ($ folders )) {
200229 foreach ($ folders as $ k => $ folder ) {
201230 $ folders [$ k ] = basename ($ folder );
@@ -221,7 +250,22 @@ public function getFolderFiles($basename = false)
221250 public function getFiles ($ basename = false , $ folder = '' )
222251 {
223252 $ pattern = function_exists ('config ' ) ? config ('logviewer.pattern ' , '*.log ' ) : '*.log ' ;
224- $ files = glob ($ this ->storage_path .'/ ' . $ folder . '/ ' . $ pattern , preg_match ($ this ->pattern ->getPattern ('files ' ), $ pattern ) ? GLOB_BRACE : 0 );
253+ $ files = glob (
254+ $ this ->storage_path . '/ ' . $ folder . '/ ' . $ pattern ,
255+ preg_match ($ this ->pattern ->getPattern ('files ' ), $ pattern ) ? GLOB_BRACE : 0
256+ );
257+ if (is_array ($ this ->storage_path )) {
258+ foreach ($ this ->storage_path as $ value ) {
259+ $ files = array_merge (
260+ $ files ,
261+ glob (
262+ $ value . '/ ' . $ folder . '/ ' . $ pattern ,
263+ preg_match ($ this ->pattern ->getPattern ('files ' ), $ pattern ) ? GLOB_BRACE : 0
264+ )
265+ );
266+ }
267+ }
268+
225269 $ files = array_reverse ($ files );
226270 $ files = array_filter ($ files , 'is_file ' );
227271 if ($ basename && is_array ($ files )) {
0 commit comments