#Can Sentry Unreal capture a message whenever a custom log category is hit?

9 messages · Page 1 of 1 (latest)

glad oracle
#

Hi,

*This behavior is sort of similar how Sentry Android works, if that helps. *

I have declared a custom log category as DECLARE_LOG_CATEGORY_EXTERN(LogDuoGame, Verbose, All); && DEFINE_LOG_CATEGORY(LogDuoGame);.

I have these log calls scattered throughout, with various verbosity levels such as Error, Log, or Verbose.

I'd like to "hook" into these log messages, so that essentially whenever I reach code like UE_LOG(LogDuoGame, Error, TEXT("%s 'ConnectionTimeout' error occurred."), *GetNameSafe(this));, sentry automatically would capture that and send it to my dashboard, similarly as if I were to do SentrySubsytem->CaptureMessage(body, verbosity); after each.

I've worked with Sentry Android extensively in the past and that seems to do just this, and I've come to really love it. I'm hoping this can be achieved here too.

glad oracle
#

I can add the Log events to existing events as breadcrumbs with the plugin configuration settings, but what I want instead is that these UE_LOG(foo) calls would trigger actual events inside sentry.

#

For example, I got critical LogDuoGame errors scattered throughout, and while these don't cause errors in the eyes of Sentry as they're handled, they are very important to me and might as well be categorized as an error.

#

I hope what I'm asking about makes a little bit more sense now.

#

These are my current settings.

sullen salmon
#

Hey @glad oracle , thank you for reaching out!

#

In Unreal SDK version 1.0.0-alpha.5 we've added a new callback which allows to pre-process breadcrumbs before adding them to Sentry (https://docs.sentry.io/platforms/unreal/enriching-events/breadcrumbs/#customize-breadcrumbs) so technically you should be able to provide your own handler that could capture a separate event whenever message with LogDuoGame category is printed to logs

#

Alternatively, you can make your own FOutputDevice implementation and hook into logs processing right in there (see FSentryOutputDevice for reference which's installed here during the plugin initialization)

glad oracle
#

Thank you for getting back to me so quickly.

It's a bit of a shame that this is not supported out-of-the-box but no big deal. In the end, I've implemented a custom macro which calls the UE_LOG macro and captures a Sentry message, while translating the verbosity to unreal's verbosity.