You are here

public function Redirect404LogSuppressor::get in Redirect 8

Retrieves the registered logger for the requested channel.

Return value

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

Overrides LoggerChannelFactoryInterface::get

File

modules/redirect_404/src/Render/Redirect404LogSuppressor.php, line 48

Class

Redirect404LogSuppressor
Allows 'page not found' events to be suppressed by returning a NullLogger.

Namespace

Drupal\redirect_404\Render

Code

public function get($channel) {
  if ($channel == 'page not found' && $this->configFactory
    ->get('redirect_404.settings')
    ->get('suppress_404')) {

    // Do not log if a 404 error is detected and the suppress_404 is enabled.
    return new NullLogger();
  }

  // Call LoggerChannelFactory to let the default logger workflow proceed.
  return $this->loggerChannelFactory
    ->get($channel);
}