public function showLog() { if (isset($this->settings[$this->key])) { $log = new LogReader($this->settings[$this->key]['path'] . $this->files[$this->key][$this->selected], $this->settings[$this->key]['delimiter'], $this->settings[$this->key]['data_regexp'], $this->settings[$this->key]['data_keys']); $timestamp = isset($_GET['timestamp']) ? intval($_GET['timestamp']) : 0; // Used for auto refresh $data = $log->readLogFile($this->position, $this->lines); $data = $log->formatLog($data); $data = array_reverse($data); foreach ($data as $line) { if (!is_a($line['datetime'], 'DateTime')) { $line['datetime'] = new DateTime(); } if (intval($line['datetime']->format('U')) > $timestamp) { $class = 'default'; if (strpos(strtolower($line['level']), 'error') !== false) { $class = 'danger'; } if (strpos(strtolower($line['level']), 'info') !== false) { $class = 'info'; } if (strpos(strtolower($line['level']), 'warn') !== false) { $class = 'warning'; } echo '<tr class="' . $class . '" data-line="' . $line['line'] . '" data-timestamp="' . $line['datetime']->format('U') . '"><td class="date-row mono-row">' . $line['datetime']->format('d-m-Y H:i:s') . '</td><td class="mono-row"><span class="level-label label label-' . $class . '">' . $line['level'] . '</span></td><td class="message"><pre>' . $line['message'] . '</pre></td></tr>'; } } } else { return ''; } }