You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.
external-logging/AuthserverExternalLoggingBu...

86 lines
2.9 KiB

<?php
/**
* Authserver, an OAuth2-based single-signon authentication provider written in PHP.
*
* Copyright (C) 2017 Lars Vierbergen
*
* his 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 <http://www.gnu.org/licenses/>.
*/
namespace vierbergenlars\AuthserverExternalLoggingBundle;
use App\Plugin\PluginEvents;
use App\Plugin\Event\ContainerConfigEvent;
use Symfony\Component\HttpKernel\Bundle\Bundle;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use vierbergenlars\AuthserverExternalLoggingBundle\DependencyInjection\AuthserverExternalLoggingExtension;
class AuthserverExternalLoggingBundle extends Bundle implements EventSubscriberInterface
{
public static function getSubscribedEvents()
{
return [
PluginEvents::CONTAINER_CONFIG => [
'onContainerConfig',
-20
]
];
}
public function onContainerConfig(ContainerConfigEvent $event)
{
$handlersManipulator = $event->getConfigManipulator('[monolog][handlers]');
$handlers = $handlersManipulator->getConfig();
if (!$handlers) {
$handlersManipulator->prependConfig([
'null' => [
'type' => 'null'
]
]);
$handlers = $handlersManipulator->getConfig();
}
foreach ($handlers as $handlerName => $conf) {
// Special types that are used to filter messages before they are logged.
if (!in_array($conf['type'], [
'fingers_crossed',
'filter',
'buffer',
'deduplication'
]))
break;
}
$handlersManipulator->prependConfig([
'vl_external_logging_splitter_' . $handlerName => [
'type' => 'whatfailuregroup',
'members' => [
$handlerName,
'vl_external_logging_entry'
]
]
], $handlerName);
$handlersManipulator->appendConfig([
'vl_external_logging_entry' => [
'type' => 'null'
]
]);
var_dump($handlersManipulator->getConfig());
}
public function getContainerExtension()
{
return new AuthserverExternalLoggingExtension();
}
}