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