Finished log configuration. All loggers are currentrly working
This commit is contained in:
@@ -253,7 +253,7 @@ abstract class AbstractCrudController extends BaseAdminController
|
||||
/**
|
||||
* Render the object list, ensuring the sort order is set.
|
||||
*
|
||||
* @return Symfony\Component\HttpFoundation\Response the response
|
||||
* @return Thelia\Core\HttpFoundation\Response the response
|
||||
*/
|
||||
protected function renderList()
|
||||
{
|
||||
@@ -263,7 +263,7 @@ abstract class AbstractCrudController extends BaseAdminController
|
||||
/**
|
||||
* The default action is displaying the list.
|
||||
*
|
||||
* @return Symfony\Component\HttpFoundation\Response the response
|
||||
* @return Thelia\Core\HttpFoundation\Response the response
|
||||
*/
|
||||
public function defaultAction()
|
||||
{
|
||||
@@ -274,7 +274,7 @@ abstract class AbstractCrudController extends BaseAdminController
|
||||
/**
|
||||
* Create a new object
|
||||
*
|
||||
* @return Symfony\Component\HttpFoundation\Response the response
|
||||
* @return Thelia\Core\HttpFoundation\Response the response
|
||||
*/
|
||||
public function createAction()
|
||||
{
|
||||
@@ -335,7 +335,7 @@ abstract class AbstractCrudController extends BaseAdminController
|
||||
/**
|
||||
* Load a object for modification, and display the edit template.
|
||||
*
|
||||
* @return Symfony\Component\HttpFoundation\Response the response
|
||||
* @return Thelia\Core\HttpFoundation\Response the response
|
||||
*/
|
||||
public function updateAction()
|
||||
{
|
||||
@@ -361,7 +361,7 @@ abstract class AbstractCrudController extends BaseAdminController
|
||||
/**
|
||||
* Save changes on a modified object, and either go back to the object list, or stay on the edition page.
|
||||
*
|
||||
* @return Symfony\Component\HttpFoundation\Response the response
|
||||
* @return Thelia\Core\HttpFoundation\Response the response
|
||||
*/
|
||||
public function processUpdateAction()
|
||||
{
|
||||
@@ -516,7 +516,7 @@ abstract class AbstractCrudController extends BaseAdminController
|
||||
/**
|
||||
* Delete an object
|
||||
*
|
||||
* @return Symfony\Component\HttpFoundation\Response the response
|
||||
* @return Thelia\Core\HttpFoundation\Response the response
|
||||
*/
|
||||
public function deleteAction()
|
||||
{
|
||||
|
||||
@@ -26,7 +26,7 @@ use Symfony\Component\Routing\Exception\InvalidParameterException;
|
||||
use Symfony\Component\Routing\Exception\MissingMandatoryParametersException;
|
||||
use Symfony\Component\Routing\Exception\RouteNotFoundException;
|
||||
use Thelia\Controller\BaseController;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Thelia\Core\HttpFoundation\Response;
|
||||
use Thelia\Core\Security\Exception\AuthorizationException;
|
||||
use Thelia\Model\ConfigQuery;
|
||||
use Symfony\Component\HttpKernel\HttpKernelInterface;
|
||||
@@ -85,7 +85,7 @@ class BaseAdminController extends BaseController
|
||||
/**
|
||||
* Return a 404 error
|
||||
*
|
||||
* @return \Symfony\Component\HttpFoundation\Response
|
||||
* @return \Thelia\Core\HttpFoundation\Response
|
||||
*/
|
||||
protected function pageNotFound()
|
||||
{
|
||||
@@ -97,7 +97,7 @@ class BaseAdminController extends BaseController
|
||||
*
|
||||
* @param mixed $message a message string, or an exception instance
|
||||
*
|
||||
* @return \Symfony\Component\HttpFoundation\Response
|
||||
* @return \Thelia\Core\HttpFoundation\Response
|
||||
*/
|
||||
protected function errorPage($message, $status = 500)
|
||||
{
|
||||
@@ -373,7 +373,7 @@ class BaseAdminController extends BaseController
|
||||
* @param $templateName the complete template name, with extension
|
||||
* @param array $args the template arguments
|
||||
* @param int $status http code status
|
||||
* @return \Symfony\Component\HttpFoundation\Response
|
||||
* @return \Thelia\Core\HttpFoundation\Response
|
||||
*/
|
||||
protected function render($templateName, $args = array(), $status = 200)
|
||||
{
|
||||
@@ -387,7 +387,7 @@ class BaseAdminController extends BaseController
|
||||
* @param array $args the template arguments
|
||||
* @param null $templateDir
|
||||
*
|
||||
* @return \Symfony\Component\HttpFoundation\Response
|
||||
* @return \Thelia\Core\HttpFoundation\Response
|
||||
*/
|
||||
protected function renderRaw($templateName, $args = array(), $templateDir = null)
|
||||
{
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
|
||||
namespace Thelia\Controller\Admin;
|
||||
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Thelia\Core\HttpFoundation\Response;
|
||||
use Thelia\Core\Security\Resource\AdminResources;
|
||||
use Thelia\Core\Event\Category\CategoryDeleteEvent;
|
||||
use Thelia\Core\Event\TheliaEvents;
|
||||
@@ -320,7 +320,7 @@ class CategoryController extends AbstractCrudController
|
||||
/**
|
||||
* Add category pictures
|
||||
*
|
||||
* @return \Symfony\Component\HttpFoundation\Response
|
||||
* @return \Thelia\Core\HttpFoundation\Response
|
||||
*/
|
||||
public function addRelatedPictureAction()
|
||||
{
|
||||
|
||||
@@ -181,7 +181,7 @@ class ConfigController extends AbstractCrudController
|
||||
/**
|
||||
* Change values modified directly from the variable list
|
||||
*
|
||||
* @return Symfony\Component\HttpFoundation\Response the response
|
||||
* @return Thelia\Core\HttpFoundation\Response the response
|
||||
*/
|
||||
public function changeValuesAction()
|
||||
{
|
||||
|
||||
@@ -64,7 +64,7 @@ class ContentController extends AbstractCrudController
|
||||
/**
|
||||
* controller adding content to additional folder
|
||||
*
|
||||
* @return mixed|\Symfony\Component\HttpFoundation\Response
|
||||
* @return mixed|\Thelia\Core\HttpFoundation\Response
|
||||
*/
|
||||
public function addAdditionalFolderAction()
|
||||
{
|
||||
@@ -92,7 +92,7 @@ class ContentController extends AbstractCrudController
|
||||
/**
|
||||
* controller removing additional folder to a content
|
||||
*
|
||||
* @return mixed|\Symfony\Component\HttpFoundation\Response
|
||||
* @return mixed|\Thelia\Core\HttpFoundation\Response
|
||||
*/
|
||||
public function removeAdditionalFolderAction()
|
||||
{
|
||||
|
||||
@@ -58,7 +58,7 @@ class CouponController extends BaseAdminController
|
||||
/**
|
||||
* Manage Coupons list display
|
||||
*
|
||||
* @return \Symfony\Component\HttpFoundation\Response
|
||||
* @return \Thelia\Core\HttpFoundation\Response
|
||||
*/
|
||||
public function browseAction()
|
||||
{
|
||||
@@ -90,7 +90,7 @@ class CouponController extends BaseAdminController
|
||||
*
|
||||
* @param int $couponId Coupon Id
|
||||
*
|
||||
* @return \Symfony\Component\HttpFoundation\Response
|
||||
* @return \Thelia\Core\HttpFoundation\Response
|
||||
*/
|
||||
public function readAction($couponId)
|
||||
{
|
||||
@@ -117,7 +117,7 @@ class CouponController extends BaseAdminController
|
||||
/**
|
||||
* Manage Coupons creation display
|
||||
*
|
||||
* @return \Symfony\Component\HttpFoundation\Response
|
||||
* @return \Thelia\Core\HttpFoundation\Response
|
||||
*/
|
||||
public function createAction()
|
||||
{
|
||||
@@ -165,7 +165,7 @@ class CouponController extends BaseAdminController
|
||||
*
|
||||
* @param int $couponId Coupon id
|
||||
*
|
||||
* @return \Symfony\Component\HttpFoundation\Response
|
||||
* @return \Thelia\Core\HttpFoundation\Response
|
||||
*/
|
||||
public function updateAction($couponId)
|
||||
{
|
||||
@@ -270,7 +270,7 @@ class CouponController extends BaseAdminController
|
||||
*
|
||||
* @param string $conditionId Condition service id
|
||||
*
|
||||
* @return \Symfony\Component\HttpFoundation\Response
|
||||
* @return \Thelia\Core\HttpFoundation\Response
|
||||
*/
|
||||
public function getConditionInputAction($conditionId)
|
||||
{
|
||||
@@ -300,7 +300,7 @@ class CouponController extends BaseAdminController
|
||||
*
|
||||
* @param int $couponId Coupon id
|
||||
*
|
||||
* @return \Symfony\Component\HttpFoundation\Response
|
||||
* @return \Thelia\Core\HttpFoundation\Response
|
||||
*/
|
||||
public function updateConditionsAction($couponId)
|
||||
{
|
||||
|
||||
@@ -61,7 +61,7 @@ class CustomerController extends BaseAdminController
|
||||
* update customer action
|
||||
*
|
||||
* @param $customer_id
|
||||
* @return mixed|\Symfony\Component\HttpFoundation\Response
|
||||
* @return mixed|\Thelia\Core\HttpFoundation\Response
|
||||
*/
|
||||
public function updateAction($customer_id)
|
||||
{
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace Thelia\Controller\Admin;
|
||||
|
||||
use Propel\Runtime\Exception\PropelException;
|
||||
use Symfony\Component\HttpFoundation\File\UploadedFile;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Thelia\Core\HttpFoundation\Response;
|
||||
use Thelia\Core\Security\Resource\AdminResources;
|
||||
use Thelia\Core\Event\Document\DocumentCreateOrUpdateEvent;
|
||||
use Thelia\Core\Event\Document\DocumentDeleteEvent;
|
||||
|
||||
@@ -117,7 +117,7 @@ class LangController extends BaseAdminController
|
||||
|
||||
$changedObject = $event->getLang();
|
||||
$this->adminLogAppend(AdminResources::LANGUAGE, AccessManager::UPDATE, sprintf("%s %s (ID %s) modified", 'Lang', $changedObject->getTitle(), $changedObject->getId()));
|
||||
$this->redirectToRoute('/admin/configuration/languages');
|
||||
$this->redirectToRoute('admin.configuration.languages');
|
||||
} catch (\Exception $e) {
|
||||
$error_msg = $e->getMessage();
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
|
||||
namespace Thelia\Controller\Admin;
|
||||
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Thelia\Core\HttpFoundation\Response;
|
||||
use Thelia\Core\Security\Resource\AdminResources;
|
||||
use Thelia\Core\Event\Order\OrderAddressEvent;
|
||||
use Thelia\Core\Event\Order\OrderEvent;
|
||||
|
||||
@@ -55,7 +55,7 @@ class ShippingZoneController extends BaseAdminController
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed|\Symfony\Component\HttpFoundation\Response
|
||||
* @return mixed|\Thelia\Core\HttpFoundation\Response
|
||||
*/
|
||||
public function addArea()
|
||||
{
|
||||
|
||||
182
core/lib/Thelia/Controller/Admin/SystemLogController.php
Normal file
182
core/lib/Thelia/Controller/Admin/SystemLogController.php
Normal file
@@ -0,0 +1,182 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* 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 General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Controller\Admin;
|
||||
|
||||
|
||||
use Thelia\Core\Security\Resource\AdminResources;
|
||||
use Thelia\Core\Security\AccessManager;
|
||||
use Thelia\Form\SystemLogConfigurationForm;
|
||||
use Thelia\Log\Tlog;
|
||||
use Thelia\Model\ConfigQuery;
|
||||
/**
|
||||
* Class LangController
|
||||
* @package Thelia\Controller\Admin
|
||||
* @author Manuel Raynaud <mraynaud@openstudio.fr>
|
||||
*/
|
||||
class SystemLogController extends BaseAdminController
|
||||
{
|
||||
|
||||
protected function renderTemplate()
|
||||
{
|
||||
$destinations = array();
|
||||
|
||||
$destination_directories = Tlog::getInstance()->getDestinationsDirectories();
|
||||
|
||||
foreach($destination_directories as $dir) {
|
||||
$this->loadDefinedDestinations($dir, $destinations);
|
||||
}
|
||||
|
||||
$active_destinations = explode(";", ConfigQuery::read(Tlog::VAR_DESTINATIONS, Tlog::DEFAUT_DESTINATIONS));
|
||||
|
||||
return $this->render('system-logs',
|
||||
array(
|
||||
'ip_address' => $this->getRequest()->getClientIp(),
|
||||
'destinations' => $destinations,
|
||||
'active_destinations' => $active_destinations
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
protected function loadDefinedDestinations($directory, &$destinations) {
|
||||
|
||||
try {
|
||||
foreach (new \DirectoryIterator($directory) as $fileInfo) {
|
||||
|
||||
if ($fileInfo->isDot()) continue;
|
||||
|
||||
$matches = array();
|
||||
|
||||
if (preg_match("/([^\.]+)\.php/", $fileInfo->getFilename(), $matches)) {
|
||||
|
||||
$classname = $matches[1];
|
||||
|
||||
if (! isset($destinations[$classname])) {
|
||||
|
||||
$full_class_name = "Thelia\\Log\\Destination\\".$classname;
|
||||
|
||||
$destinations[$classname] = new $full_class_name();
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (\UnexpectedValueException $ex) {
|
||||
// Directory does no exists -> Nothing to do
|
||||
}
|
||||
}
|
||||
|
||||
public function defaultAction()
|
||||
{
|
||||
if (null !== $response = $this->checkAuth(AdminResources::SYSTEM_LOG, AccessManager::VIEW)) return $response;
|
||||
|
||||
/*
|
||||
const VAR_LEVEL = "tlog_level";
|
||||
const VAR_DESTINATIONS = "tlog_destinations";
|
||||
const VAR_PREFIXE = "tlog_prefix";
|
||||
const VAR_FILES = "tlog_files";
|
||||
const VAR_IP = "tlog_ip";
|
||||
const VAR_SHOW_REDIRECT = "tlog_show_redirect";
|
||||
|
||||
const DEFAULT_LEVEL = self::DEBUG;
|
||||
const DEFAUT_DESTINATIONS = "Thelia\Log\Destination\TlogDestinationFile";
|
||||
const DEFAUT_PREFIXE = "#NUM: #NIVEAU [#FICHIER:#FONCTION()] {#LIGNE} #DATE #HEURE: ";
|
||||
const DEFAUT_FILES = "*";
|
||||
const DEFAUT_IP = "";
|
||||
const DEFAUT_SHOW_REDIRECT = 0;
|
||||
|
||||
*/
|
||||
|
||||
// Hydrate the general configuration form
|
||||
$systemLogForm = new SystemLogConfigurationForm($this->getRequest(), 'form', array(
|
||||
'level' => ConfigQuery::read(Tlog::VAR_LEVEL, Tlog::DEFAULT_LEVEL),
|
||||
'format' => ConfigQuery::read(Tlog::VAR_PREFIXE, Tlog::DEFAUT_PREFIXE),
|
||||
'show_redirections' => ConfigQuery::read(Tlog::VAR_SHOW_REDIRECT, Tlog::DEFAUT_SHOW_REDIRECT),
|
||||
'files' => ConfigQuery::read(Tlog::VAR_FILES, Tlog::DEFAUT_FILES),
|
||||
'ip_addresses' => ConfigQuery::read(Tlog::VAR_IP, Tlog::DEFAUT_IP),
|
||||
));
|
||||
|
||||
$this->getParserContext()->addForm($systemLogForm);
|
||||
|
||||
return $this->renderTemplate();
|
||||
}
|
||||
|
||||
public function saveAction()
|
||||
{
|
||||
if (null !== $response = $this->checkAuth(AdminResources::LANGUAGE, AccessManager::UPDATE)) return $response;
|
||||
|
||||
$error_msg = false;
|
||||
|
||||
$systemLogForm = new SystemLogConfigurationForm($this->getRequest());
|
||||
|
||||
try {
|
||||
$form = $this->validateForm($systemLogForm);
|
||||
|
||||
$data = $form->getData();
|
||||
|
||||
ConfigQuery::write(Tlog::VAR_LEVEL , $data['level']);
|
||||
ConfigQuery::write(Tlog::VAR_PREFIXE , $data['format']);
|
||||
ConfigQuery::write(Tlog::VAR_SHOW_REDIRECT , $data['show_redirections']);
|
||||
ConfigQuery::write(Tlog::VAR_FILES , $data['files']);
|
||||
ConfigQuery::write(Tlog::VAR_IP , $data['ip_addresses']);
|
||||
|
||||
// Save destination configuration
|
||||
$destinations = $this->getRequest()->get('destinations');
|
||||
$configs = $this->getRequest()->get('config');
|
||||
|
||||
$active_destinations = array();
|
||||
|
||||
foreach($destinations as $classname => $destination) {
|
||||
|
||||
if (isset($destination['active'])) {
|
||||
$active_destinations[] = $destination['classname'];
|
||||
}
|
||||
|
||||
if (isset($configs[$classname])) {
|
||||
|
||||
// Update destinations configuration
|
||||
foreach($configs[$classname] as $var => $value) {
|
||||
ConfigQuery::write($var, $value, true, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Update active destinations list
|
||||
ConfigQuery::write(Tlog::VAR_DESTINATIONS, implode(';', $active_destinations));
|
||||
|
||||
$this->adminLogAppend(AdminResources::SYSTEM_LOG, AccessManager::UPDATE, "System log configuration changed");
|
||||
|
||||
$this->redirectToRoute('admin.configuration.system-logs.default');
|
||||
|
||||
} catch (\Exception $ex) {
|
||||
$error_msg = $ex->getMessage();
|
||||
}
|
||||
|
||||
$this->setupFormErrorContext(
|
||||
$this->getTranslator()->trans("System log configuration failed."),
|
||||
$error_msg,
|
||||
$systemLogForm,
|
||||
$ex
|
||||
);
|
||||
|
||||
return $this->renderTemplate();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user