How to filter out messages

Created on 22 November 2023, over 1 year ago
Updated 23 November 2023, over 1 year ago

We are upgrading from 3.x to 5.x and in the process have to replace our hook_raven_filter_alter() implementation with an EventSubscriber.

In the hook implementation, the message could be accessed using $filter['message'] and the message was unformatted, meaning that placeholders were not substituted. For example, when editing a node, the message would be "@type: updated %title."

However when using the EventSubscriber, $breadcrumb->getMessage() is returning the formatted message, such as "page: updated test page." There doesn't seem to be any method in the breadcrumb to get the unformatted message.

How could we access the unfiltered message in 5.x, so that we can filter in the same way as with 3.x?

Thanks

πŸ’¬ Support request
Status

Fixed

Version

5.0

Component

Miscellaneous

Created by

πŸ‡¬πŸ‡§United Kingdom nicrodgers Monmouthshire, UK

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

Comments & Activities

  • Issue created by @nicrodgers
  • πŸ‡ΊπŸ‡ΈUnited States mfb San Francisco

    I would suggest that we should add the uninterpolated message to the breadcrumb data, if it differs from the interpolated message.

  • Status changed to Fixed over 1 year ago
  • πŸ‡¬πŸ‡§United Kingdom nicrodgers Monmouthshire, UK

    Turns out this is already possible, I was doing it wrong.

    We re-wrote hook_raven_filter_alter() as an event subscriber listening for onOptionsAlter, and within the handler we have to modify before_send

    $alterEvent->options['before_send'] = function (Event $event): ? Event {
      if ($event->getLogger() === $channel && $event->getMessage() === '@type: updated %title.' )) {
        return NULL;
      }
      return $event;
    }
    
    
  • πŸ‡ΊπŸ‡ΈUnited States mfb San Francisco

    Yes, this allows you to filter log events by that message. However, it will not allow you to filter breadcrumbs by that message, which you mentioned in the original issue summary. If you also need to filter breadcrumbs then this should be reopened as a feature request.

  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024