diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 12:39:39 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 12:39:39 +0000 |
commit | 8ca6cc32b2c789a3149861159ad258f2cb9491e3 (patch) | |
tree | 2492de6f1528dd44eaa169a5c1555026d9cb75ec /application/controllers/ListController.php | |
parent | Initial commit. (diff) | |
download | icingaweb2-upstream.tar.xz icingaweb2-upstream.zip |
Adding upstream version 2.11.4.upstream/2.11.4upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | application/controllers/ListController.php | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/application/controllers/ListController.php b/application/controllers/ListController.php new file mode 100644 index 0000000..2fbc5a9 --- /dev/null +++ b/application/controllers/ListController.php @@ -0,0 +1,59 @@ +<?php +/* Icinga Web 2 | (c) 2014 Icinga Development Team | GPLv2+ */ + +namespace Icinga\Controllers; + +use Icinga\Application\Config; +use Icinga\Application\Logger; +use Icinga\Data\ConfigObject; +use Icinga\Protocol\File\FileReader; +use Icinga\Web\Controller; +use Icinga\Web\Url; +use Icinga\Web\Widget\Tabextension\DashboardAction; +use Icinga\Web\Widget\Tabextension\MenuAction; +use Icinga\Web\Widget\Tabextension\OutputFormat; + +/** + * Application wide controller for various listing actions + */ +class ListController extends Controller +{ + /** + * Add title tab + * + * @param string $action + */ + protected function addTitleTab($action) + { + $this->getTabs()->add($action, array( + 'label' => ucfirst($action), + 'url' => Url::fromPath('list/' . str_replace(' ', '', $action)) + ))->extend(new OutputFormat())->extend(new DashboardAction())->extend(new MenuAction())->activate($action); + } + + /** + * Display the application log + */ + public function applicationlogAction() + { + $this->assertPermission('application/log'); + + if (! Logger::writesToFile()) { + $this->httpNotFound('Page not found'); + } + + $this->addTitleTab('application log'); + + $resource = new FileReader(new ConfigObject(array( + 'filename' => Config::app()->get('logging', 'file'), + 'fields' => '/(?<!.)(?<datetime>[0-9]{4}(?:-[0-9]{2}){2}' // date + . 'T[0-9]{2}(?::[0-9]{2}){2}(?:[\+\-][0-9]{2}:[0-9]{2})?)' // time + . ' - (?<loglevel>[A-Za-z]+) - (?<message>.*)(?!.)/msS' // loglevel, message + ))); + $this->view->logData = $resource->select()->order('DESC'); + + $this->setupLimitControl(); + $this->setupPaginationControl($this->view->logData); + $this->view->title = $this->translate('Application Log'); + } +} |