2014-04-01 05:48:44 -04:00
|
|
|
<?php
|
2016-02-08 09:41:00 -05:00
|
|
|
/* Icinga Web 2 | (c) 2014 Icinga Development Team | GPLv2+ */
|
2014-04-01 05:48:44 -04:00
|
|
|
|
2015-08-27 07:34:37 -04:00
|
|
|
namespace Icinga\Controllers;
|
|
|
|
|
|
2015-04-07 04:34:55 -04:00
|
|
|
use Icinga\Application\Config;
|
2014-10-31 05:27:17 -04:00
|
|
|
use Icinga\Application\Logger;
|
2014-11-18 07:11:52 -05:00
|
|
|
use Icinga\Data\ConfigObject;
|
2014-09-04 09:29:11 -04:00
|
|
|
use Icinga\Protocol\File\FileReader;
|
2015-07-28 05:33:33 -04:00
|
|
|
use Icinga\Web\Controller;
|
|
|
|
|
use Icinga\Web\Url;
|
|
|
|
|
use Icinga\Web\Widget\Tabextension\DashboardAction;
|
2015-09-30 08:47:42 -04:00
|
|
|
use Icinga\Web\Widget\Tabextension\MenuAction;
|
2015-07-28 05:33:33 -04:00
|
|
|
use Icinga\Web\Widget\Tabextension\OutputFormat;
|
2014-04-01 05:48:44 -04:00
|
|
|
|
2014-04-02 07:23:18 -04:00
|
|
|
/**
|
|
|
|
|
* Application wide controller for various listing actions
|
|
|
|
|
*/
|
2014-04-01 05:48:44 -04:00
|
|
|
class ListController extends Controller
|
|
|
|
|
{
|
2014-04-02 07:23:18 -04:00
|
|
|
/**
|
|
|
|
|
* Add title tab
|
|
|
|
|
*
|
|
|
|
|
* @param string $action
|
|
|
|
|
*/
|
2014-04-01 05:48:44 -04:00
|
|
|
protected function addTitleTab($action)
|
|
|
|
|
{
|
|
|
|
|
$this->getTabs()->add($action, array(
|
2015-02-23 11:00:30 -05:00
|
|
|
'label' => ucfirst($action),
|
2017-01-27 08:48:59 -05:00
|
|
|
'url' => Url::fromPath('list/' . str_replace(' ', '', $action))
|
2015-09-30 08:47:42 -04:00
|
|
|
))->extend(new OutputFormat())->extend(new DashboardAction())->extend(new MenuAction())->activate($action);
|
2014-04-01 05:48:44 -04:00
|
|
|
}
|
|
|
|
|
|
2014-04-02 07:23:18 -04:00
|
|
|
/**
|
|
|
|
|
* Display the application log
|
|
|
|
|
*/
|
2014-04-01 05:48:44 -04:00
|
|
|
public function applicationlogAction()
|
|
|
|
|
{
|
2016-03-02 14:47:22 -05:00
|
|
|
$this->assertPermission('application/log');
|
|
|
|
|
|
2014-09-05 09:28:39 -04:00
|
|
|
if (! Logger::writesToFile()) {
|
2015-07-28 05:33:33 -04:00
|
|
|
$this->httpNotFound('Page not found');
|
2014-09-05 09:28:39 -04:00
|
|
|
}
|
|
|
|
|
|
2014-04-01 05:48:44 -04:00
|
|
|
$this->addTitleTab('application log');
|
2014-09-03 07:12:22 -04:00
|
|
|
|
2014-11-18 07:11:52 -05:00
|
|
|
$resource = new FileReader(new ConfigObject(array(
|
2015-04-07 04:34:55 -04:00
|
|
|
'filename' => Config::app()->get('logging', 'file'),
|
2015-04-24 10:30:29 -04:00
|
|
|
'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
|
2014-09-05 09:28:39 -04:00
|
|
|
)));
|
2015-05-15 08:32:58 -04:00
|
|
|
$this->view->logData = $resource->select()->order('DESC');
|
2015-04-17 10:09:17 -04:00
|
|
|
|
|
|
|
|
$this->setupLimitControl();
|
|
|
|
|
$this->setupPaginationControl($this->view->logData);
|
2019-07-12 04:22:01 -04:00
|
|
|
$this->view->title = $this->translate('Application Log');
|
2014-04-01 05:48:44 -04:00
|
|
|
}
|
|
|
|
|
}
|