fix: Format PubSubRoute as json in log msgs

It was previously using the default ToString, which simply returns the type name
This commit is contained in:
John Colvin committed 2025-11-03 16:19:48 -05:00
1 parent d80cd9c0fd
commit a01fc6cc15
1 file changed
+5 -4
@@ -10,6 +10,7 @@ using Microsoft.Extensions.Options;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.Json;
namespace BCG {
public class PubSubRouter : IPubSubRouter {
@@ -30,10 +31,10 @@ namespace BCG {
public PubSubRouter(PubSubRoute[] sub_routes, PubSubRoute[] pub_routes) {
string log_msg = String.Empty;
foreach (var route in sub_routes) {
log_msg += $" sub_route: {route}";
log_msg += $" sub_route: {JsonSerializer.Serialize(route)}";
}
foreach (var route in pub_routes) {
log_msg += $" pub_route: {route}";
log_msg += $" pub_route: {JsonSerializer.Serialize(route)}";
}
Log.Gen.info($"PubSubRouter routes: {log_msg}");
_sub_routes = sub_routes;
@@ -50,7 +51,7 @@ namespace BCG {
if (!_pub_routes.TryGetFirst(r => r?.IsMatch(tag) ?? false, out var route)) {
throw new ArgumentException($"Failed to find route for tag '{tag}'", nameof(tag));
}
Log.Gen.info($"PubSubRouter.get_sub_url_for_tag tag: {tag} route: {route}");
Log.Gen.info($"PubSubRouter.get_sub_url_for_tag tag: {tag} route: {JsonSerializer.Serialize(route)}");
ArgumentNullException.ThrowIfNull(route.ServerAddress);
return RemoteConnectionInfo.parse_url(route.ServerAddress);
}
@@ -59,7 +60,7 @@ namespace BCG {
if (!_sub_routes.TryGetFirst(r => r?.IsMatch(tag) ?? false, out var route)) {
throw new ArgumentException($"Failed to find route for tag '{tag}'", nameof(tag));
}
Log.Gen.info($"PubSubRouter.get_sub_url_for_tag tag: {tag} route: {route}");
Log.Gen.info($"PubSubRouter.get_sub_url_for_tag tag: {tag} route: {JsonSerializer.Serialize(route)}");
ArgumentNullException.ThrowIfNull(route.ServerAddress);
return RemoteConnectionInfo.parse_url(route.ServerAddress);
}