| 812 | public SimpleSplat.LogLevel Level { get; set; } |
| 813 | |
| 814 | public SetupLogLogger(bool saveInTemp, string commandSuffix = null) |
| 815 | { |
| 816 | for (int i=0; i < 10; i++) { |
| 817 | try { |
| 818 | var dir = saveInTemp ? |
| 819 | Path.GetTempPath() : |
| 820 | Path.GetDirectoryName(Assembly.GetEntryAssembly().Location); |
| 821 | var fileName = commandSuffix == null ? String.Format($"Squirrel.{i}.log", i) : String.Format($"Squirrel-{commandSuffix}.{i}.log", i); |
| 822 | var file = Path.Combine(dir, fileName.Replace(".0.log", ".log")); |
| 823 | var str = File.Open(file, FileMode.Append, FileAccess.Write, FileShare.Read); |
| 824 | inner = new StreamWriter(str, Encoding.UTF8, 4096, false) { AutoFlush = true }; |
| 825 | return; |
| 826 | } catch (Exception ex) { |
| 827 | // Didn't work? Keep going |
| 828 | Console.Error.WriteLine("Couldn't open log file, trying new file: " + ex.ToString()); |
| 829 | } |
| 830 | } |
| 831 | |
| 832 | inner = Console.Error; |
| 833 | } |
| 834 | |
| 835 | public void Write(string message, LogLevel logLevel) |
| 836 | { |