friendica/src/Module/Admin/Logs/View.php

64 lines
2 KiB
PHP
Raw Normal View History

2019-05-02 06:01:43 +02:00
<?php
2020-02-09 15:45:36 +01:00
/**
2021-03-29 08:40:20 +02:00
* @copyright Copyright (C) 2010-2021, the Friendica project
2020-02-09 15:45:36 +01:00
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
2019-05-02 06:01:43 +02:00
namespace Friendica\Module\Admin\Logs;
2020-01-18 22:07:07 +01:00
use Friendica\DI;
use Friendica\Core\Renderer;
use Friendica\Core\Theme;
2020-01-23 05:14:14 +01:00
use Friendica\Module\BaseAdmin;
use Friendica\Model\Log\ParsedLogIterator;
2019-05-02 06:01:43 +02:00
2020-01-23 05:14:14 +01:00
class View extends BaseAdmin
2019-05-02 06:01:43 +02:00
{
const LIMIT = 500;
public static function content(array $parameters = [])
2019-05-02 06:01:43 +02:00
{
2019-11-05 21:22:54 +01:00
parent::content($parameters);
2019-05-02 06:01:43 +02:00
$t = Renderer::getMarkupTemplate('admin/logs/view.tpl');
DI::page()->registerFooterScript(Theme::getPathForFile('js/module/admin/logs/view.js'));
$f = DI::config()->get('system', 'logfile');
$data = null;
$error = null;
2019-05-02 06:01:43 +02:00
if (!file_exists($f)) {
$error = DI::l10n()->t('Error trying to open <strong>%1$s</strong> log file.\r\n<br/>Check to see if file %1$s exist and is readable.', $f);
2019-05-02 06:01:43 +02:00
} else {
try {
$data = new ParsedLogIterator($f, self::LIMIT);
} catch (Exception $e) {
$error = DI::l10n()->t('Couldn\'t open <strong>%1$s</strong> log file.\r\n<br/>Check to see if file %1$s is readable.', $f);
2019-05-02 06:01:43 +02:00
}
}
return Renderer::replaceMacros($t, [
'$title' => DI::l10n()->t('Administration'),
'$page' => DI::l10n()->t('View Logs'),
2019-05-02 06:01:43 +02:00
'$data' => $data,
'$error' => $error,
'$logname' => DI::config()->get('system', 'logfile')
2019-05-02 06:01:43 +02:00
]);
}
}