19 lines
823 B
C#
19 lines
823 B
C#
using PlotDirector.Companion.Agent;
|
|
internal static class Program
|
|
{
|
|
[STAThread]
|
|
private static int Main(string[] args)
|
|
{
|
|
#if WINDOWS
|
|
return TrayApplication.Run(args);
|
|
#else
|
|
Console.Error.WriteLine("Run the Windows tray Companion on Windows; portable tests use its net10.0 core.");return 2;
|
|
#endif
|
|
}
|
|
}
|
|
internal sealed class AgentLog(string directory)
|
|
{
|
|
private readonly object gate=new();
|
|
public void Write(string message){lock(gate){try{var path=Path.Combine(directory,"agent.jsonl");if(File.Exists(path)&&new FileInfo(path).Length>2*1024*1024)File.Move(path,path+".previous",true);File.AppendAllText(path,System.Text.Json.JsonSerializer.Serialize(new{utc=DateTime.UtcNow,component="agent",message})+Environment.NewLine);}catch(IOException){}catch(UnauthorizedAccessException){}}}
|
|
}
|