fix(worker): drop SignalR hub invocation events so PATs stay out of the worker log
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 5.5
parent
c834f17c78
commit
61645acf17
@@ -0,0 +1,15 @@
|
||||
using Serilog.Events;
|
||||
|
||||
namespace ClaudeDo.Worker.Logging;
|
||||
|
||||
/// <summary>Logger-level filter keeping hub invocation arguments (PATs) out of every sink.</summary>
|
||||
public static class HubLogFilter
|
||||
{
|
||||
private const string Dispatcher = "Microsoft.AspNetCore.SignalR.Internal.DefaultHubDispatcher";
|
||||
|
||||
/// <summary>True for the DefaultHubDispatcher events that print the invocation message including its arguments.</summary>
|
||||
public static bool IsInvocationWithArguments(LogEvent e) =>
|
||||
e.Properties.TryGetValue("SourceContext", out var src) && src is ScalarValue { Value: Dispatcher }
|
||||
&& e.Properties.TryGetValue("EventId", out var id) && id is StructureValue sv
|
||||
&& sv.Properties.FirstOrDefault(p => p.Name == "Name")?.Value is ScalarValue { Value: "ReceivedHubInvocation" or "ReceivedStreamHubInvocation" };
|
||||
}
|
||||
@@ -65,6 +65,8 @@ builder.Host.UseSerilog((ctx, lc) => lc
|
||||
// see it either, since SignalR rejects the invocation while parsing the message, before any
|
||||
// hub method (and its filter pipeline) is dispatched.
|
||||
.MinimumLevel.Override("Microsoft.AspNetCore.SignalR.Internal.DefaultHubDispatcher", Serilog.Events.LogEventLevel.Debug)
|
||||
// The same Debug override logs every invocation's arguments (PATs); drop just those events for all sinks.
|
||||
.Filter.ByExcluding(ClaudeDo.Worker.Logging.HubLogFilter.IsInvocationWithArguments)
|
||||
.WriteTo.File(
|
||||
System.IO.Path.Combine(logRoot, "worker-.log"),
|
||||
rollingInterval: RollingInterval.Day,
|
||||
|
||||
Reference in New Issue
Block a user