namespace SilverOS.Welcome.App;

// Lightweight always-on file logger for first-boot diagnosis. The Welcome app
// runs as the kiosk shell with no console and (in Release) no debugger, so when
// something fails silently (blank WebView, chrome not applied) there is nowhere
// to look. This writes to a world-writable ProgramData path that survives the
// session and can be read off the disk image.
public static class Diag
{
    const string Dir = @"C:\ProgramData\SilverMetal";
    const string Path = Dir + @"\welcome.log";
    static readonly object _lock = new();

    public static void Log(string msg)
    {
        try
        {
            System.IO.Directory.CreateDirectory(Dir);
            lock (_lock)
                System.IO.File.AppendAllText(Path, $"{DateTime.Now:HH:mm:ss.fff} {msg}{Environment.NewLine}");
        }
        catch { /* logging must never throw */ }
    }
}
