Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. LoggerChannelTrait.php

function LoggerChannelTrait::getLogger

Gets the logger for a specific channel.

@todo Require the use of injected services: https://www.drupal.org/node/2733703

Parameters

string $channel: The name of the channel. Can be any string, but the general practice is to use the name of the subsystem calling this.

Return value

\Psr\Log\LoggerInterface The logger for the given channel.

3 calls to LoggerChannelTrait::getLogger()
FormBase::logger in core/lib/Drupal/Core/Form/FormBase.php
Gets the logger for a specific channel.
ImageStyleDownloadController::__construct in core/modules/image/src/Controller/ImageStyleDownloadController.php
Constructs an ImageStyleDownloadController object.
SearchController::__construct in core/modules/search/src/Controller/SearchController.php
Constructs a new search controller.

File

core/lib/Drupal/Core/Logger/LoggerChannelTrait.php, line 37

Class

LoggerChannelTrait
Wrapper methods for the logger factory service.

Namespace

Drupal\Core\Logger

Code

protected function getLogger($channel) {
    if (!$this->loggerFactory) {
        $this->loggerFactory = \Drupal::service('logger.factory');
    }
    return $this->loggerFactory
        ->get($channel);
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal