You are here

private function NewRelicLogger::shouldLog in New Relic 2.0.x

Same name and namespace in other branches
  1. 8 src/Logger/NewRelicLogger.php \Drupal\new_relic_rpm\Logger\NewRelicLogger::shouldLog()
  2. 2.x src/Logger/NewRelicLogger.php \Drupal\new_relic_rpm\Logger\NewRelicLogger::shouldLog()

Check whether we should log the message or not based on the level.

We exclude logging to certain levels through configuration, but we also send only the latest most severe message we receive. This is because Newrelic only supports setting one newrelic_notice_error().

Parameters

int $level: The RFC 5424 log level.

Return value

bool Indicator of whether the message should be logged or not.

1 call to NewRelicLogger::shouldLog()
NewRelicLogger::log in src/Logger/NewRelicLogger.php

File

src/Logger/NewRelicLogger.php, line 76

Class

NewRelicLogger
A Logger that allows sending messages to the New Relic API.

Namespace

Drupal\new_relic_rpm\Logger

Code

private function shouldLog($level) {

  // Always log the most severe latest message.
  if ($level > $this->lastLoggedLevel) {
    return FALSE;
  }
  $validLevels = $this->configFactory
    ->get('new_relic_rpm.settings')
    ->get('watchdog_severities') ?: [];
  return in_array($level, $validLevels);
}