class DBLogFilter in DBLog Filter 8.2
Same name and namespace in other branches
- 8 src/Logger/DBLogFilter.php \Drupal\dblog_filter\Logger\DBLogFilter
DBLogFilter Class.
Hierarchy
- class \Drupal\dblog\Logger\DbLog implements \Psr\Log\LoggerInterface uses DependencySerializationTrait, RfcLoggerTrait
- class \Drupal\dblog_filter\Logger\DBLogFilter uses RfcLoggerTrait
Expanded class hierarchy of DBLogFilter
File
- src/
Logger/ DBLogFilter.php, line 14
Namespace
Drupal\dblog_filter\LoggerView source
class DBLogFilter extends DbLog {
use RfcLoggerTrait;
/**
* Constructs a DbLogFilter object.
*
* @param \Drupal\Core\Database\Connection $connection
* The database connection object.
* @param \Drupal\Core\Logger\LogMessageParserInterface $parser
* The parser to use when extracting message variables.
*/
public function __construct(Connection $connection, LogMessageParserInterface $parser) {
$this->connection = $connection;
$this->parser = $parser;
}
/**
* {@inheritdoc}
*/
public function log($level, $message, array $context = array()) {
$level_explode = array();
$result = FALSE;
// Get RFC LOg levels.
$levels = RfcLogLevel::getLevels();
// Get Log Filter Settings.
$config = \Drupal::config('dblog_filter.settings');
// Get Severity levels Configuration.
$severity_levels = $config
->get('severity_levels');
$entities_load = $config
->get('log_values');
$values = array_map('trim', explode("\n", $entities_load));
foreach ($levels as $key => $log_level) {
$level_array[$key] = strtolower($log_level
->getUntranslatedString());
}
// Check for channel name and given values in log filter settings.
foreach ($values as $value) {
$explode_values = explode('|', $value);
if ($explode_values[0] == $context['channel']) {
$level_explode = explode(',', $explode_values[1]);
}
}
if ($level_explode) {
$result = in_array($level_array[$level], $level_explode);
}
if (!empty($severity_levels[$level_array[$level]])) {
$result = TRUE;
}
// If present the only log message.
if ($result) {
parent::log($level, $message, $context);
}
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
DbLog:: |
protected | property | The database connection object. | |
DbLog:: |
protected | property | The message's placeholders parser. | |
DbLog:: |
constant | The dedicated database connection target to use for log entries. | ||
DBLogFilter:: |
public | function |
Logs with an arbitrary level. Overrides RfcLoggerTrait:: |
|
DBLogFilter:: |
public | function |
Constructs a DbLogFilter object. Overrides DbLog:: |
|
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 | |
RfcLoggerTrait:: |
public | function | ||
RfcLoggerTrait:: |
public | function | ||
RfcLoggerTrait:: |
public | function | ||
RfcLoggerTrait:: |
public | function | ||
RfcLoggerTrait:: |
public | function | ||
RfcLoggerTrait:: |
public | function | ||
RfcLoggerTrait:: |
public | function | ||
RfcLoggerTrait:: |
public | function |