Filtering by log level broken on 5.x branch

Created on 14 November 2023, about 1 year ago

Problem/Motivation

I want to subscribe to the event so I can change the sentry client options. I want to send only the breadcrums of certain levels with the parameter 'before_breadcrumb'

Steps to reproduce

Create an event subscriber:

<?php

namespace Drupal\raven_sict\EventSubscriber;

use Symfony\Component\EventDispatcher\EventSubscriberInterface;

/**
 * Subscriber for Raven OptionsAlter event.
 */
class RavenOptionsAlterSubscriber implements EventSubscriberInterface {

  /**
   * {@inheritdoc}
   */
  public static function getSubscribedEvents() {
    $events[\Drupal\raven\Event\OptionsAlter::class] = ['onOptionsAlter'];
    return $events;
  }

  /**
   * Alter options.
   *
   * @param \Drupal\raven\Event\OptionsAlter $alterEvent
   *   The Policy Alter event.
   */
  public function onOptionsAlter(\Drupal\raven\Event\OptionsAlter $alterEvent): void {
    // Disable Breadcrumb (Logging)
    // https://docs.sentry.io/platforms/php/enriching-events/breadcrumbs/#customize-breadcrumbs
    $alterEvent->options['before_breadcrumb'] = function (\Sentry\Breadcrumb $breadcrumb): ?\Sentry\Breadcrumb {
      if (in_array($breadcrumb->getLevel(), ['warning', 'error', 'fatal'])) {
        return $breadcrumb;
      }
      return null;
    };
  }

}

In https://sentry.io all levels are captured (info, debug, ...). Options changes don't seem to apply.

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

πŸ› Bug report
Status

Fixed

Version

5.0

Component

Code

Created by

πŸ‡ͺπŸ‡ΈSpain carles.zapater

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024