class Redirect404LogSuppressor in Redirect 8
Allows 'page not found' events to be suppressed by returning a NullLogger.
Hierarchy
- class \Drupal\redirect_404\Render\Redirect404LogSuppressor implements LoggerChannelFactoryInterface uses DependencySerializationTrait
Expanded class hierarchy of Redirect404LogSuppressor
1 string reference to 'Redirect404LogSuppressor'
- redirect_404.services.yml in modules/
redirect_404/ redirect_404.services.yml - modules/redirect_404/redirect_404.services.yml
1 service uses Redirect404LogSuppressor
- logger.redirect_404 in modules/
redirect_404/ redirect_404.services.yml - \Drupal\redirect_404\Render\Redirect404LogSuppressor
File
- modules/
redirect_404/ src/ Render/ Redirect404LogSuppressor.php, line 15
Namespace
Drupal\redirect_404\RenderView source
class Redirect404LogSuppressor implements LoggerChannelFactoryInterface {
use DependencySerializationTrait;
/**
* The logger channel factory.
*
* @var \Drupal\Core\Logger\LoggerChannelFactoryInterface
*/
protected $loggerChannelFactory;
/**
* The configuration factory.
*
* @var \Drupal\Core\Config\ConfigFactoryInterface
*/
protected $configFactory;
/**
* Constructs a Redirect404LogSuppressor object.
*
* @param \Drupal\Core\Logger\LoggerChannelFactoryInterface $logger_channel_factory
* The logger channel factory.
* @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory
* The configuration factory.
*/
public function __construct(LoggerChannelFactoryInterface $logger_channel_factory, ConfigFactoryInterface $config_factory) {
$this->loggerChannelFactory = $logger_channel_factory;
$this->configFactory = $config_factory;
}
/**
* {@inheritdoc}
*/
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);
}
/**
* {@inheritdoc}
*/
public function addLogger(LoggerInterface $logger, $priority = 0) {
$this->loggerChannelFactory
->addLogger($logger, $priority);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
DependencySerializationTrait:: |
protected | property | An array of entity type IDs keyed by the property name of their storages. | |
DependencySerializationTrait:: |
protected | property | An array of service IDs keyed by property name used for serialization. | |
DependencySerializationTrait:: |
public | function | 1 | |
DependencySerializationTrait:: |
public | function | 2 | |
Redirect404LogSuppressor:: |
protected | property | The configuration factory. | |
Redirect404LogSuppressor:: |
protected | property | The logger channel factory. | |
Redirect404LogSuppressor:: |
public | function |
Adds a logger to all the channels. Overrides LoggerChannelFactoryInterface:: |
|
Redirect404LogSuppressor:: |
public | function |
Retrieves the registered logger for the requested channel. Overrides LoggerChannelFactoryInterface:: |
|
Redirect404LogSuppressor:: |
public | function | Constructs a Redirect404LogSuppressor object. |