Skip to content

Commit 2a55796

Browse files
gilesrussirap2hpoutre
authored andcommitted
Add timezone to logs (#108)
1 parent 499263b commit 2a55796

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/Rap2hpoutre/LaravelLogViewer/LaravelLogViewer.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ public static function pathToLogFile($file)
8080
if (app('files')->exists($file)) { // try the absolute path
8181
return $file;
8282
}
83-
83+
8484
$file = $logsPath . '/' . $file;
8585

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

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

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

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

141141
$log[] = array(
142-
'context' => $current[2],
142+
'context' => $current[3],
143143
'level' => $level,
144144
'level_class' => self::$levels_classes[$level],
145145
'level_img' => self::$levels_imgs[$level],
146146
'date' => $current[1],
147-
'text' => $current[3],
148-
'in_file' => isset($current[4]) ? $current[4] : null,
147+
'text' => $current[4],
148+
'in_file' => isset($current[5]) ? $current[5] : null,
149149
'stack' => preg_replace("/^\n*/", '', $log_data[$i])
150150
);
151151
}

0 commit comments

Comments
 (0)