You are here

protected function FileLog::shouldLog in File Log 8

Same name and namespace in other branches
  1. 2.0.x src/Logger/FileLog.php \Drupal\filelog\Logger\FileLog::shouldLog()

Decides whether a message should be logged or ignored.

Parameters

mixed $level: Severity level of the log message.

string $message: Content of the log message.

array $context: Context of the log message.

Return value

bool TRUE if the message should be logged, FALSE otherwise.

1 call to FileLog::shouldLog()
FileLog::log in src/Logger/FileLog.php
Logs with an arbitrary level.

File

src/Logger/FileLog.php, line 186

Class

FileLog
File-based logger.

Namespace

Drupal\filelog\Logger

Code

protected function shouldLog($level, $message, array $context = []) : bool {

  // Ignore any messages below the configured severity.
  // (Severity decreases with level.)
  $should_log = $this->config
    ->get('enabled') && $level <= $this->config
    ->get('level');

  // Include or exclude based on channel list.
  $should_log = $should_log && ($this->config
    ->get('channels_type') === 'include') === in_array($context['channel'], $this->config
    ->get('channels'), TRUE);
  return $should_log;
}