Skip to content

Commit

Permalink
Use OnMessageFilter event from Elmah.Io.Client
Browse files Browse the repository at this point in the history
  • Loading branch information
ThomasArdal committed Jun 27, 2024
1 parent 64f789d commit b33c265
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/Elmah.Io.Functions/MessageShipper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,6 @@ public static async Task Ship(FunctionExceptionContext exceptionContext, HttpCon
Application = options.Application,
};

if (options.OnFilter != null && options.OnFilter(createMessage))
{
return;
}

if (elmahIoClient == null)
{
elmahIoClient = ElmahioAPI.Create(options.ApiKey, new ElmahIoOptions
Expand All @@ -59,6 +54,15 @@ public static async Task Ship(FunctionExceptionContext exceptionContext, HttpCon
UserAgent = UserAgent(),
});

elmahIoClient.Messages.OnMessageFilter += (sender, args) =>
{
var filter = options.OnFilter?.Invoke(args.Message);
if (filter.HasValue && filter.Value)
{
args.Filter = true;
}
};

elmahIoClient.Messages.OnMessage += (sender, args) =>
{
options.OnMessage?.Invoke(args.Message);
Expand Down

0 comments on commit b33c265

Please sign in to comment.