MCPcopy Create free account
hub / github.com/Squirrel/Squirrel.Windows / SetupLogLogger

Method SetupLogLogger

src/Update/Program.cs:814–833  ·  view source on GitHub ↗
(bool saveInTemp, string commandSuffix = null)

Source from the content-addressed store, hash-verified

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 {

Callers

nothing calls this directly

Calls 4

FormatMethod · 0.80
ReplaceMethod · 0.45
OpenMethod · 0.45
ToStringMethod · 0.45

Tested by

no test coverage detected