You are here

class LoggerChannelFactory in TMGMT Translator Smartling 8.4

Same name and namespace in other branches
  1. 8.3 modules/tmgmt_smartling_log_settings/src/Logger/LoggerChannelFactory.php \Drupal\tmgmt_smartling_log_settings\Logger\LoggerChannelFactory

Defines a factory for logging channels.

Hierarchy

Expanded class hierarchy of LoggerChannelFactory

1 file declares its use of LoggerChannelFactory
TmgmtSmartlingLogSettingsServiceProvider.php in modules/tmgmt_smartling_log_settings/src/TmgmtSmartlingLogSettingsServiceProvider.php

File

modules/tmgmt_smartling_log_settings/src/Logger/LoggerChannelFactory.php, line 10

Namespace

Drupal\tmgmt_smartling_log_settings\Logger
View source
class LoggerChannelFactory extends LoggerChannelFactoryCore {

  /**
   * {@inheritdoc}
   */
  public function get($channel) {
    if (!isset($this->channels[$channel])) {

      // Same as core's LoggerChannelFactory but we instantiate
      // Drupal\tmgmt_smartling_log_settings\Logger\LoggerChannel instead
      // of Drupal\Core\Logger\LoggerChannelFactory.
      $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];
  }

}

Members

Namesort descending Modifiers Type Description Overrides
LoggerChannelFactory::$channels protected property Array of all instantiated logger channels keyed by channel name.
LoggerChannelFactory::$loggers protected property An array of arrays of \Psr\Log\LoggerInterface keyed by priority.
LoggerChannelFactory::addLogger public function Adds a logger to all the channels. Overrides LoggerChannelFactoryInterface::addLogger
LoggerChannelFactory::get public function Retrieves the registered logger for the requested channel. Overrides LoggerChannelFactory::get