-
Notifications
You must be signed in to change notification settings - Fork 118
Expand file tree
/
Copy pathRulesLoggerChannel.php
More file actions
51 lines (43 loc) · 1.16 KB
/
RulesLoggerChannel.php
File metadata and controls
51 lines (43 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<?php
/**
* @file
* Contains \Drupal\rules\Logger\RulesLoggerChannel.
*/
namespace Drupal\rules\Logger;
use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\Config\ImmutableConfig;
use Drupal\Core\Logger\LoggerChannel;
use Psr\Log\LoggerTrait;
/**
* Logs rules log entries in the available loggers.
*/
class RulesLoggerChannel extends LoggerChannel {
use LoggerTrait;
/**
* A configuration object with rules settings.
*
* @var ImmutableConfig
*/
protected $config;
/**
* Creates RulesLoggerChannel object.
*
* @param ConfigFactoryInterface $config_factory
* Config factory instance.
*/
public function __construct(ConfigFactoryInterface $config_factory) {
parent::__construct('rules');
$this->config = $config_factory->get('rules.settings');
}
/**
* {@inheritdoc}
*/
public function log($level, $message, array $context = []) {
// Log message only if rules logging setting is enabled.
if ($this->config->get('debug_log')) {
if ($this->levelTranslation[$this->config->get('log_errors')] >= $this->levelTranslation[$level]) {
parent::log($level, $message, $context);
}
}
}
}