Skip to content

Commit f33e343

Browse files
committed
Sets log level at autoclient startup
1 parent 855b627 commit f33e343

File tree

3 files changed

+27
-0
lines changed

3 files changed

+27
-0
lines changed

ProjectPlugins/CodexClient/CodexAccess.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,22 @@ public DebugInfo GetDebugInfo()
5151
return mapper.Map(OnCodex(api => api.GetDebugInfoAsync()));
5252
}
5353

54+
public void SetLogLevel(string logLevel)
55+
{
56+
try
57+
{
58+
OnCodex(async api =>
59+
{
60+
await api.SetDebugLogLevelAsync(logLevel);
61+
return string.Empty;
62+
});
63+
}
64+
catch (Exception exc)
65+
{
66+
log.Error("Failed to set log level: " + exc);
67+
}
68+
}
69+
5470
public string GetSpr()
5571
{
5672
return CrashCheck(() =>

ProjectPlugins/CodexClient/CodexNode.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ public partial interface ICodexNode : IHasEthAddress, IHasMetricsScrapeTarget
1111
string GetImageName();
1212
string GetPeerId();
1313
DebugInfo GetDebugInfo(bool log = false);
14+
void SetLogLevel(string logLevel);
1415
string GetSpr();
1516
DebugPeer GetDebugPeer(string peerId);
1617
ContentId UploadFile(TrackedFile file);
@@ -135,6 +136,11 @@ public DebugInfo GetDebugInfo(bool log = false)
135136
return debugInfo;
136137
}
137138

139+
public void SetLogLevel(string logLevel)
140+
{
141+
codexAccess.SetLogLevel(logLevel);
142+
}
143+
138144
public string GetSpr()
139145
{
140146
return codexAccess.GetSpr();

Tools/AutoClient/Program.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,8 @@ private CodexWrapper[] CreateCodexWrappers()
8989
return result.ToArray();
9090
}
9191

92+
private readonly string LogLevel = "TRACE;info:discv5,providers,routingtable,manager,cache;warn:libp2p,multistream,switch,transport,tcptransport,semaphore,asyncstreamwrapper,lpstream,mplex,mplexchannel,noise,bufferstream,mplexcoder,secure,chronosstream,connection,websock,ws-session,muxedupgrade,upgrade,identify,contracts,clock,serde,json,serialization,JSONRPC-WS-CLIENT,JSONRPC-HTTP-CLIENT,codex,repostore";
93+
9294
private CodexWrapper CreateCodexWrapper(string endpoint)
9395
{
9496
var splitIndex = endpoint.LastIndexOf(':');
@@ -103,6 +105,9 @@ private CodexWrapper CreateCodexWrapper(string endpoint)
103105

104106
var instance = CodexInstance.CreateFromApiEndpoint("[AutoClient]", address, EthAccountGenerator.GenerateNew());
105107
var node = app.CodexNodeFactory.CreateCodexNode(instance);
108+
109+
node.SetLogLevel(LogLevel);
110+
106111
return new CodexWrapper(app, node);
107112
}
108113

0 commit comments

Comments
 (0)