You are here

public function Raven::__construct in Raven: Sentry Integration 8

Same name and namespace in other branches
  1. 8.2 src/Logger/Raven.php \Drupal\raven\Logger\Raven::__construct()
  2. 3.x src/Logger/Raven.php \Drupal\raven\Logger\Raven::__construct()

Constructs a Raven log object.

Parameters

\Drupal\Core\Config\ConfigFactoryInterface $config_factory: The configuration factory object.

\Drupal\Core\Logger\LogMessageParserInterface $parser: The parser to use when extracting message variables.

File

src/Logger/Raven.php, line 42

Class

Raven

Namespace

Drupal\raven\Logger

Code

public function __construct(ConfigFactoryInterface $config_factory, LogMessageParserInterface $parser) {
  if (!class_exists('Raven_Client')) {

    // Sad raven.
    return;
  }
  $this->config = $config_factory
    ->get('raven.settings');
  $this->parser = $parser;
  $this->client = new Raven_Client($this->config
    ->get('client_key'), [
    'auto_log_stacks' => $this->config
      ->get('stack'),
    'curl_method' => 'async',
    'processorOptions' => [
      'Raven_SanitizeDataProcessor' => [
        'fields_re' => '/(SESS|pass|authorization|password|passwd|secret|password_confirmation|card_number|auth_pw)/i',
      ],
    ],
    'timeout' => $this->config
      ->get('timeout'),
    'trace' => $this->config
      ->get('trace'),
  ]);

  // Raven can catch fatal errors which are not caught by the Drupal logger.
  if ($this->config
    ->get('fatal_error_handler')) {
    $error_handler = new Raven_ErrorHandler($this->client);
    $error_handler
      ->registerShutdownFunction($this->config
      ->get('fatal_error_handler_memory'));
  }
}