class MonologServiceProvider in Monolog 8
Same name and namespace in other branches
- 2.x src/MonologServiceProvider.php \Drupal\monolog\MonologServiceProvider
Overrides the logger.factory service with the monolog factory.
Hierarchy
- class \Drupal\Core\DependencyInjection\ServiceProviderBase implements ServiceModifierInterface, ServiceProviderInterface
- class \Drupal\monolog\MonologServiceProvider
Expanded class hierarchy of MonologServiceProvider
File
- src/
MonologServiceProvider.php, line 12
Namespace
Drupal\monologView source
class MonologServiceProvider extends ServiceProviderBase {
/**
* {@inheritdoc}
*/
public function alter(ContainerBuilder $container) {
$definition = $container
->getDefinition('logger.factory');
$definition
->setClass('Drupal\\monolog\\Logger\\MonologLoggerChannelFactory')
->clearTags();
// Allow existing Drupal loggers to be added as handlers.
$drupalLoggers = $container
->findTaggedServiceIds('logger');
foreach ($drupalLoggers as $id => $tags) {
$handlerId = sprintf('monolog.handler.drupal.%s', preg_replace('/^logger\\./', '', $id));
// Allow the handler to be explicitly defined elsewhere.
if (!$container
->has($handlerId)) {
$definition = $container
->register($handlerId, 'Drupal\\monolog\\Logger\\Handler\\DrupalHandler');
$definition
->addArgument(new Reference($id));
}
}
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
MonologServiceProvider:: |
public | function |
Modifies existing service definitions. Overrides ServiceProviderBase:: |
|
ServiceProviderBase:: |
public | function |
Registers services to the container. Overrides ServiceProviderInterface:: |
1 |