Open Data Catalog v2.0.0
LoggerTrait.php
Go to the documentation of this file.
1 <?php
2 
3 namespace Drupal\dkan_common;
4 
5 use Drupal\Core\Logger\LoggerChannelFactory;
6 use Psr\Log\LogLevel;
7 
11 trait LoggerTrait {
17  private $loggerService;
18 
25  public function setLoggerFactory(LoggerChannelFactory $loggerService) {
26  $this->loggerService = $loggerService;
27  }
28 
32  private function log($loggerName, $message, $variables = [], $level = LogLevel::ERROR) {
33  if ($this->loggerService) {
34  $this->loggerService->get($loggerName)->log($level, $message, $variables);
35  }
36  }
37 
38 }
Drupal\dkan_common\setLoggerFactory
setLoggerFactory(LoggerChannelFactory $loggerService)
Definition: LoggerTrait.php:25
Drupal\dkan_common
Definition: AbstractDataNodeLifeCycle.php:3
Drupal\dkan_common\LoggerTrait
trait LoggerTrait
Definition: LoggerTrait.php:11