Simpler trace output files

This commit is contained in:
Ben 2025-05-22 12:43:58 +02:00
parent 306e2c6583
commit 62e5f523e8
No known key found for this signature in database
GPG Key ID: 0F16E812E736C24B
2 changed files with 11 additions and 21 deletions

View File

@ -1,5 +1,4 @@
using System.IO.Compression;
using System.Numerics;
using System.Numerics;
using CodexContractsPlugin.ChainMonitor;
using CodexContractsPlugin.Marketplace;
using Logging;
@ -24,18 +23,16 @@ namespace TraceContract
private readonly ILog log;
private readonly List<Entry> entries = new();
private readonly string folder;
private readonly List<string> files = new();
private readonly Input input;
private readonly Config config;
public Output(ILog log, Input input, Config config)
{
folder = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString());
folder = config.GetOuputFolder();
Directory.CreateDirectory(folder);
var filename = Path.Combine(folder, $"contract_{input.PurchaseId}");
var fileLog = new FileLog(filename);
files.Add(fileLog.FullFilename + ".log");
foreach (var pair in config.LogReplacements)
{
fileLog.AddStringReplace(pair.Key, pair.Value);
@ -101,9 +98,14 @@ namespace TraceContract
public LogFile CreateNodeLogTargetFile(string node)
{
var file = log.CreateSubfile(node);
files.Add(file.Filename);
return file;
return log.CreateSubfile(node);
}
public void ShowOutputFiles(ILog console)
{
console.Log("Files in output folder:");
var files = Directory.GetFiles(folder);
foreach (var file in files) console.Log(file);
}
private void Write(Entry e)
@ -116,16 +118,6 @@ namespace TraceContract
Add(call.Block.Utc, $"Reserve-slot called. Index: {call.SlotIndex} Host: '{call.FromAddress}'");
}
public string Package()
{
var outputFolder = config.GetOuputFolder();
Directory.CreateDirectory(outputFolder);
var filename = Path.Combine(outputFolder, $"contract_{input.PurchaseId}.zip");
ZipFile.CreateFromDirectory(folder, filename);
return filename;
}
private void Add(DateTime utc, string msg)
{
entries.Add(new Entry(utc, msg));

View File

@ -55,9 +55,7 @@ namespace TraceContract
Log("Downloading storage nodes logs for the request timerange...");
DownloadStorageNodeLogs(requestTimeRange, entryPoint.Tools);
Log("Packaging...");
var zipFilename = output.Package();
Log($"Saved to '{zipFilename}'");
output.ShowOutputFiles(log);
entryPoint.Decommission(false, false, false);
Log("Done");