Skip to content

Commit

Permalink
Log target when connection limiter throws
Browse files Browse the repository at this point in the history
  • Loading branch information
smoogipoo committed Jan 30, 2024
1 parent 510fd9b commit 6f75d8d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion osu.Server.Spectator/ConcurrentConnectionLimiter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ private static void log(HubLifetimeContext context, string message)
bool connectionIsValid = tokenIdMatches && hubRegistered && connectionIdMatches;

if (!connectionIsValid)
throw new InvalidStateException("State is not valid for this connection");
throw new InvalidStateException($"State is not valid for this connection, context: {LoggingHubFilter.GetMethodCallDisplayString(invocationContext)})");
}

return await next(invocationContext);
Expand Down
6 changes: 3 additions & 3 deletions osu.Server.Spectator/LoggingHubFilter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ public class LoggingHubFilter : IHubFilter
try
{
if (DebugUtils.IsDebugBuild)
logTarget.Log($"Invoking hub method: {getMethodCallDisplayString(invocationContext)}", LogLevel.Debug);
logTarget.Log($"Invoking hub method: {GetMethodCallDisplayString(invocationContext)}", LogLevel.Debug);

return await next(invocationContext);
}
catch (Exception e)
{
logTarget.Error($"Failed to invoke hub method: {getMethodCallDisplayString(invocationContext)}", e);
logTarget.Error($"Failed to invoke hub method: {GetMethodCallDisplayString(invocationContext)}", e);
throw;
}
}
Expand Down Expand Up @@ -68,7 +68,7 @@ public async Task OnDisconnectedAsync(HubLifetimeContext context, Exception? exc
}
}

private static string getMethodCallDisplayString(HubInvocationContext invocationContext)
public static string GetMethodCallDisplayString(HubInvocationContext invocationContext)
{
var methodCall = $"{invocationContext.HubMethodName}({string.Join(", ", invocationContext.HubMethodArguments.Select(getReadableString))})";
return methodCall;
Expand Down

0 comments on commit 6f75d8d

Please sign in to comment.