37 lines
1.3 KiB
C#
37 lines
1.3 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Globalization;
|
|
using System.IO;
|
|
using System.Text;
|
|
|
|
namespace HellionChat.SelfTests;
|
|
|
|
// Shared report sink so manual self-test steps leave a readable trace on disk. Each
|
|
// call appends a timestamped block to selftest-report.log in the plugin ConfigDirectory;
|
|
// the human reads the tail after running the self-test runner.
|
|
// Append (not atomic tmp+move) is fine: the runner is single-threaded on the
|
|
// draw thread and a torn trailing line on a crash is acceptable for a debug log.
|
|
internal static class SelfTestReport
|
|
{
|
|
internal static string Append(string stepName, string status, IReadOnlyList<string> details)
|
|
{
|
|
var path = Path.Join(Plugin.Interface.ConfigDirectory.FullName, "selftest-report.log");
|
|
|
|
var stamp = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture);
|
|
var sb = new StringBuilder();
|
|
sb.Append("=== ")
|
|
.Append(stamp)
|
|
.Append(" | ")
|
|
.Append(stepName)
|
|
.Append(" | ")
|
|
.Append(status)
|
|
.Append(" ===\n");
|
|
foreach (var line in details)
|
|
sb.Append(" ").Append(line).Append('\n');
|
|
sb.Append('\n');
|
|
|
|
File.AppendAllText(path, sb.ToString());
|
|
return path;
|
|
}
|
|
}
|