Skip to content

Commit

Permalink
Update LaravelLogViewer.php
Browse files Browse the repository at this point in the history
  • Loading branch information
rap2hpoutre committed Apr 7, 2015
1 parent 8559d0f commit e6a3f0b
Showing 1 changed file with 19 additions and 14 deletions.
33 changes: 19 additions & 14 deletions src/Rap2hpoutre/LaravelLogViewer/LaravelLogViewer.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,7 @@ public static function all()

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


if (!self::$file) {
$log_file = self::getFiles();
if(!count($log_file)) {
return [];
}
self::$file = $log_file[0];
}

$file = File::get(self::$file);
$file = self::getCurrentFile();

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

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

preg_match('/^\[(\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2})\].*?\.' . $level . ': (.*?)( in .*?:[0-9]+)?$/', $h[$i], $current);



$log[] = array(
'level' => $ll,
'level_class' => $levels_classes[$ll],
Expand All @@ -113,8 +103,7 @@ public static function all()
}
}

$log = array_reverse($log);
return $log;
return array_reverse($log);
}

/**
Expand All @@ -132,4 +121,20 @@ public static function getFiles($basename = false)
}
return $files;
}

/**
* @return array
*/
private static function getCurrentFile()
{
if (!self::$file) {
$log_file = self::getFiles();
if(!count($log_file)) {
return [];
}
self::$file = $log_file[0];
}

return File::get(self::$file);
}
}

0 comments on commit e6a3f0b

Please sign in to comment.