class LoggerChannelFactory in Service Container 7
Same name and namespace in other branches
- 7.2 src/Logger/LoggerChannelFactory.php \Drupal\service_container\Logger\LoggerChannelFactory
Defines a factory for logging channels.
Hierarchy
- class \Drupal\service_container\Logger\LoggerChannelFactory implements LoggerChannelFactoryInterface
Expanded class hierarchy of LoggerChannelFactory
1 file declares its use of LoggerChannelFactory
- LoggerChannelFactoryTest.php in tests/
src/ Logger/ LoggerChannelFactoryTest.php - Contains \Drupal\Tests\service_container\Logger\LoggerChannelFactoryTest.
File
- src/
Logger/ LoggerChannelFactory.php, line 16 - Contains \Drupal\service_container\Logger\LoggerChannelFactory.
Namespace
Drupal\service_container\LoggerView source
class LoggerChannelFactory implements LoggerChannelFactoryInterface {
/**
* Array of all instantiated logger channels keyed by channel name.
*
* @var \Drupal\Core\Logger\LoggerChannelInterface[]
*/
protected $channels = array();
/**
* An array of arrays of \Psr\Log\LoggerInterface keyed by priority.
*
* @var array
*/
protected $loggers = array();
/**
* {@inheritdoc}
*/
public function get($channel) {
if (!isset($this->channels[$channel])) {
$instance = new LoggerChannel($channel);
// Pass the loggers to the channel.
$instance
->setLoggers($this->loggers);
$this->channels[$channel] = $instance;
}
return $this->channels[$channel];
}
/**
* {@inheritdoc}
*/
public function addLogger(LoggerInterface $logger, $priority = 0) {
// Store it so we can pass it to potential new logger instances.
$this->loggers[$priority][] = $logger;
// Add the logger to already instantiated channels.
foreach ($this->channels as $channel) {
$channel
->addLogger($logger, $priority);
}
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
LoggerChannelFactory:: |
protected | property | Array of all instantiated logger channels keyed by channel name. | |
LoggerChannelFactory:: |
protected | property | An array of arrays of \Psr\Log\LoggerInterface keyed by priority. | |
LoggerChannelFactory:: |
public | function |
Adds a logger. Overrides LoggerChannelFactoryInterface:: |
|
LoggerChannelFactory:: |
public | function |
Retrieves the registered logger for the requested channel. Overrides LoggerChannelFactoryInterface:: |