public function LoggerChannelFactory::get

public LoggerChannelFactory::get($channel)

Retrieves the registered logger for the requested channel.

Return value

\Drupal\Core\Logger\LoggerChannelInterface The registered logger for this channel.

Overrides LoggerChannelFactoryInterface::get

File

core/lib/Drupal/Core/Logger/LoggerChannelFactory.php, line 32

Class

LoggerChannelFactory
Defines a factory for logging channels.

Namespace

Drupal\Core\Logger

Code

public function get($channel) {
  if (!isset($this->channels[$channel])) {
    $instance = new LoggerChannel($channel);

    // If we have a container set the request_stack and current_user services
    // on the channel. It is up to the channel to determine if there is a
    // current request.
    if ($this->container) {
      $instance->setRequestStack($this->container->get('request_stack'));
      $instance->setCurrentUser($this->container->get('current_user'));
    }

    // Pass the loggers to the channel.
    $instance->setLoggers($this->loggers);
    $this->channels[$channel] = $instance;
  }

  return $this->channels[$channel];
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Logger!LoggerChannelFactory.php/function/LoggerChannelFactory::get/8.1.x