mirror of
https://github.com/par274/sharpemu.git
synced 2026-07-31 15:09:42 +08:00
[logging] Add FileLogSink, CompositeLogSink, and SHARPEMU_LOG_FILE env support (#50)
- FileLogSink: thread-safe file writer with AutoFlush, FileShare.Read for concurrent read access (tail -f), automatic parent directory creation, full date-time timestamps, IDisposable for graceful shutdown - CompositeLogSink: fan-out to multiple sinks with per-sink exception isolation (one broken sink cannot silence the others), IDisposable propagates to children - SharpEmuLog: ResolveSinkFromEnvironment() reads SHARPEMU_LOG_FILE and creates CompositeLogSink(console + file) when set; Sink setter now disposes the previous IDisposable sink to prevent file handle leaks; Shutdown() flushes and disposes the active sink - Program.cs: Main wrapped in try/finally to guarantee SharpEmuLog.Shutdown() runs on all exit paths (GUI, mitigated child, normal, exception) Co-authored-by: Hermes Atlas <hermesatlas@example.com>
This commit is contained in:
@@ -36,6 +36,18 @@ internal static partial class Program
|
||||
|
||||
[STAThread]
|
||||
private static int Main(string[] args)
|
||||
{
|
||||
try
|
||||
{
|
||||
return Run(args);
|
||||
}
|
||||
finally
|
||||
{
|
||||
SharpEmuLog.Shutdown();
|
||||
}
|
||||
}
|
||||
|
||||
private static int Run(string[] args)
|
||||
{
|
||||
args = NormalizeInternalArguments(args, out var isMitigatedChild);
|
||||
if (args.Length == 0 && !isMitigatedChild)
|
||||
@@ -66,7 +78,7 @@ internal static partial class Program
|
||||
|
||||
ebootPath = Path.GetFullPath(ebootPath);
|
||||
Console.Error.WriteLine($"[DEBUG] Full path: {ebootPath}");
|
||||
|
||||
|
||||
if (!File.Exists(ebootPath))
|
||||
{
|
||||
Log.Error($"EBOOT file was not found: {ebootPath}");
|
||||
|
||||
Reference in New Issue
Block a user