protected function DiagnosticsService::getLogger in Purge 8.3
Initialize and retrieve the logger via lazy loading.
Return value
\Drupal\purge\Logger\LoggerChannelPartInterface The logger instance.
File
- src/
Plugin/ Purge/ DiagnosticCheck/ DiagnosticsService.php, line 127
Class
- DiagnosticsService
- Provides a service that interacts with diagnostic checks.
Namespace
Drupal\purge\Plugin\Purge\DiagnosticCheckCode
protected function getLogger() {
if (is_null($this->logger)) {
$purge_logger = $this->container
->get('purge.logger');
$channel_name = 'diagnostics';
// By default ::get() would autocreate the channel with grants that are
// too broad. Therefore precreate it with only the ERROR grant.
if (!$purge_logger
->hasChannel($channel_name)) {
$purge_logger
->setChannel($channel_name, [
RfcLogLevel::ERROR,
]);
}
$this->logger = $purge_logger
->get($channel_name);
}
return $this->logger;
}