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 8, 2015
1 parent 5d17466 commit dbd405d
Showing 1 changed file with 28 additions and 23 deletions.
51 changes: 28 additions & 23 deletions src/Rap2hpoutre/LaravelLogViewer/LaravelLogViewer.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,28 @@ class LaravelLogViewer
*/
private static $file;

private static $levels_classes = [
'debug' => 'info',
'info' => 'info',
'notice' => 'info',
'warning' => 'warning',
'error' => 'danger',
'critical' => 'danger',
'alert' => 'danger',
];

private static $levels_imgs = [
'debug' => 'info',
'info' => 'info',
'notice' => 'info',
'warning' => 'warning',
'error' => 'warning',
'critical' => 'warning',
'alert' => 'warning',
];



/**
* @param string $file
*/
Expand Down Expand Up @@ -58,38 +80,21 @@ public static function all()
array_shift($log_data);
}

$levels_classes = [
'debug' => 'info',
'info' => 'info',
'notice' => 'info',
'warning' => 'warning',
'error' => 'danger',
'critical' => 'danger',
'alert' => 'danger',
];
$levels_imgs = [
'debug' => 'info',
'info' => 'info',
'notice' => 'info',
'warning' => 'warning',
'error' => 'warning',
'critical' => 'warning',
'alert' => 'warning',
];

foreach ($headings as $h) {
for ($i=0, $j = count($h); $i < $j; $i++) {
foreach ($log_levels as $level_key => $level_value) {
if (strpos(strtolower($h[$i]), '.' . $level_value)) {

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

if (!isset($current[2])) continue;

$log[] = array(
'level' => $level_value,
'level_class' => $levels_classes[$level_value],
'level_img' => $levels_imgs[$level_value],
'date' => isset($current[1]) ? $current[1] : null,
'text' => isset($current[2]) ? $current[2] : null,
'level_class' => self::$levels_classes[$level_value],
'level_img' => self::$levels_imgs[$level_value],
'date' => $current[1],
'text' => $current[2],
'in_file' => isset($current[3]) ? $current[3] : null,
'stack' => preg_replace("/^\n*/", '', $log_data[$i])
);
Expand Down

0 comments on commit dbd405d

Please sign in to comment.