Sets log level at autoclient startup

This commit is contained in:
ThatBen 2025-03-03 16:44:04 +01:00
parent 855b627823
commit f33e343432
No known key found for this signature in database
GPG Key ID: 62C543548433D43E
3 changed files with 27 additions and 0 deletions

View File

@ -51,6 +51,22 @@ namespace CodexClient
return mapper.Map(OnCodex(api => api.GetDebugInfoAsync()));
}
public void SetLogLevel(string logLevel)
{
try
{
OnCodex(async api =>
{
await api.SetDebugLogLevelAsync(logLevel);
return string.Empty;
});
}
catch (Exception exc)
{
log.Error("Failed to set log level: " + exc);
}
}
public string GetSpr()
{
return CrashCheck(() =>

View File

@ -11,6 +11,7 @@ namespace CodexClient
string GetImageName();
string GetPeerId();
DebugInfo GetDebugInfo(bool log = false);
void SetLogLevel(string logLevel);
string GetSpr();
DebugPeer GetDebugPeer(string peerId);
ContentId UploadFile(TrackedFile file);
@ -135,6 +136,11 @@ namespace CodexClient
return debugInfo;
}
public void SetLogLevel(string logLevel)
{
codexAccess.SetLogLevel(logLevel);
}
public string GetSpr()
{
return codexAccess.GetSpr();

View File

@ -89,6 +89,8 @@ public class Program
return result.ToArray();
}
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";
private CodexWrapper CreateCodexWrapper(string endpoint)
{
var splitIndex = endpoint.LastIndexOf(':');
@ -103,6 +105,9 @@ public class Program
var instance = CodexInstance.CreateFromApiEndpoint("[AutoClient]", address, EthAccountGenerator.GenerateNew());
var node = app.CodexNodeFactory.CreateCodexNode(instance);
node.SetLogLevel(LogLevel);
return new CodexWrapper(app, node);
}