/** * Gets the logger for a specific channel. * * @param string $channel * The name of the channel. * * @return \Psr\Log\LoggerInterface * The logger for this channel */ protected function logger($channel) { if (!$this->loggerFactory) { $this->loggerFactory = \Drupal::service('logger.factory'); } return $this->loggerFactory->get($channel); }
/** * Tests LoggerChannelFactory::get(). * * @covers ::get */ public function testGet() { $factory = new LoggerChannelFactory(); $factory->setContainer($this->getMock('Symfony\\Component\\DependencyInjection\\ContainerInterface')); // Ensure that when called with the same argument, always the same instance // will be returned. $this->assertSame($factory->get('test'), $factory->get('test')); }
/** * Constructor for MetatagManager. * * @param MetatagGroupPluginManager $groupPluginManager * @param MetatagTagPluginManager $tagPluginManager * @param MetatagToken $token */ public function __construct(MetatagGroupPluginManager $groupPluginManager, MetatagTagPluginManager $tagPluginManager, MetatagToken $token, LoggerChannelFactory $channelFactory) { $this->groupPluginManager = $groupPluginManager; $this->tagPluginManager = $tagPluginManager; $this->tokenService = $token; $this->logger = $channelFactory->get('metatag'); }
/** * Constructor. * * @param ConfigFactoryInterface $config_factory * The configuration factory. * @param UrlGeneratorInterface $url_generator * The URL generator. * @param Connection $database_connection * The database service. * @param LoggerChannelFactory $logger_factory * The logger channel factory. */ public function __construct(ConfigFactoryInterface $config_factory, UrlGeneratorInterface $url_generator, Connection $database_connection, LoggerChannelFactory $logger_factory) { $this->urlGenerator = $url_generator; $this->connection = $database_connection; $this->settings = $config_factory->get('cas.settings'); $this->loggerChannel = $logger_factory->get('cas'); }