3 * @copyright Copyright (C) 2010-2021, the Friendica project
5 * @license GNU AGPL version 3 or any later version
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU Affero General Public License as
9 * published by the Free Software Foundation, either version 3 of the
10 * License, or (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU Affero General Public License for more details.
17 * You should have received a copy of the GNU Affero General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
22 namespace Friendica\Module\Admin\Logs;
25 use Friendica\Core\Renderer;
26 use Friendica\Core\Theme;
27 use Friendica\Module\BaseAdmin;
30 class View extends BaseAdmin
34 public static function content(array $parameters = [])
36 parent::content($parameters);
38 $t = Renderer::getMarkupTemplate('admin/logs/view.tpl');
39 DI::page()->registerFooterScript(Theme::getPathForFile('js/module/admin/logs/view.js'));
41 $f = DI::config()->get('system', 'logfile');
45 $search = $_GET['q'] ?? '';
47 $filters_valid_values = [
57 'context' => ['', 'index', 'worker'],
60 'level' => $_GET['level'] ?? '',
61 'context' => $_GET['context'] ?? '',
63 foreach ($filters as $k => $v) {
64 if ($v == '' || !in_array($v, $filters_valid_values[$k])) {
69 if (!file_exists($f)) {
70 $error = DI::l10n()->t('Error trying to open <strong>%1$s</strong> log file.<br/>Check to see if file %1$s exist and is readable.', $f);
73 $data = DI::parsedLogIterator()
75 ->withLimit(self::LIMIT)
76 ->withFilters($filters)
77 ->withSearch($search);
78 } catch (Exception $e) {
79 $error = DI::l10n()->t('Couldn\'t open <strong>%1$s</strong> log file.<br/>Check to see if file %1$s is readable.', $f);
82 return Renderer::replaceMacros($t, [
83 '$title' => DI::l10n()->t('Administration'),
84 '$page' => DI::l10n()->t('View Logs'),
86 'Search' => DI::l10n()->t('Search'),
87 'Search_in_logs' => DI::l10n()->t('Search in logs'),
88 'Show_all' => DI::l10n()->t('Show all'),
89 'Date' => DI::l10n()->t('Date'),
90 'Level' => DI::l10n()->t('Level'),
91 'Context' => DI::l10n()->t('Context'),
92 'Message' => DI::l10n()->t('Message'),
93 'ALL' => DI::l10n()->t('ALL'),
94 'View_details' => DI::l10n()->t('View details'),
95 'Click_to_view_details' => DI::l10n()->t('Click to view details'),
96 'Event_details' => DI::l10n()->t('Event details'),
97 'Data' => DI::l10n()->t('Data'),
98 'Source' => DI::l10n()->t('Source'),
99 'File' => DI::l10n()->t('File'),
100 'Line' => DI::l10n()->t('Line'),
101 'Function' => DI::l10n()->t('Function'),
102 'UID' => DI::l10n()->t('UID'),
103 'Process_ID' => DI::l10n()->t('Process ID'),
104 'Close' => DI::l10n()->t('Close'),
108 '$filters' => $filters,
109 '$filtersvalues' => $filters_valid_values,
111 '$baseurl' => DI::baseUrl()->get(true),
112 '$logname' => DI::config()->get('system', 'logfile'),