Skip to content

Commit

Permalink
Add timezone to logs (#108)
Browse files Browse the repository at this point in the history
  • Loading branch information
gilesrussi authored and rap2hpoutre committed Nov 17, 2017
1 parent 499263b commit 2a55796
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/Rap2hpoutre/LaravelLogViewer/LaravelLogViewer.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public static function pathToLogFile($file)
if (app('files')->exists($file)) { // try the absolute path
return $file;
}

$file = $logsPath . '/' . $file;

// check if requested file is really in the logs directory
Expand All @@ -106,7 +106,7 @@ public static function all()
{
$log = array();

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

if (!self::$file) {
$log_file = self::getFiles();
Expand Down Expand Up @@ -135,17 +135,17 @@ public static function all()
foreach (self::$log_levels as $level) {
if (strpos(strtolower($h[$i]), '.' . $level) || strpos(strtolower($h[$i]), $level . ':')) {

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

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

0 comments on commit 2a55796

Please sign in to comment.