diff --git a/src/Nethermind/Nethermind.JsonRpc/JsonRpcUrlCollection.cs b/src/Nethermind/Nethermind.JsonRpc/JsonRpcUrlCollection.cs index b7a60475d2f..591e520c988 100644 --- a/src/Nethermind/Nethermind.JsonRpc/JsonRpcUrlCollection.cs +++ b/src/Nethermind/Nethermind.JsonRpc/JsonRpcUrlCollection.cs @@ -89,6 +89,7 @@ private void BuildEngineUrls(bool includeWebSockets) private void BuildAdditionalUrls(bool includeWebSockets) { + List additionalRpcUrlRows = new List(); foreach (string additionalRpcUrl in _jsonRpcConfig.AdditionalRpcUrls) { try @@ -118,6 +119,13 @@ private void BuildAdditionalUrls(bool includeWebSockets) else { Add(url.Port, url); + string[] row = new[] + { + $"{url.Host}:{url.Port}", + url.RpcEndpoint.ToString(), + string.Join(", ", url.EnabledModules) + }; + additionalRpcUrlRows.Add(row); } } catch (FormatException fe) @@ -125,6 +133,40 @@ private void BuildAdditionalUrls(bool includeWebSockets) if (_logger.IsInfo) _logger.Info($"Additional JSON RPC URL packed value '{additionalRpcUrl}' format error: {fe.Message}; skipping..."); } } + LogTable(additionalRpcUrlRows); + } + private void LogTable(List rows) + { + + string[] headers = ["Additional Url", "Protocols", "Modules"]; + string redSeparator = "\u001b[31m|\u001b[0m"; + var columnWidths = new int[headers.Length]; + + for (int i = 0; i < headers.Length; i++) + { + columnWidths[i] = headers[i].Length; + foreach (var row in rows) + { + if (i < row.Length) + { + columnWidths[i] = Math.Max(columnWidths[i], row[i]?.Length ?? 0); + } + } + } + + var separator = "-" + string.Join("-", columnWidths.Select(width => new string('-', width + 2))) + "-"; + + _logger.Info("\u001b[31m*****\u001b[0m Additional RPC URLs \u001b[31m*****\u001b[0m"); + _logger.Info(separator); + _logger.Info(redSeparator + " " + string.Join(" " + redSeparator + " ", headers.Select((h, i) => h.PadRight(columnWidths[i]))) + " " + redSeparator); + _logger.Info(separator); + + foreach (var row in rows) + { + _logger.Info(redSeparator + " " + string.Join(" " + redSeparator + " ", row.Select((cell, i) => (cell ?? "").PadRight(columnWidths[i]))) + " " + redSeparator); + } + + _logger.Info(separator); } }