public void Dispose() { Console.SetOut(oldConsoleOut); mirrorWriter = null; logStreamWriter.Flush(); logStreamWriter = null; logFileStream.Flush(); logFileStream.Close(); logFileStream = null; }
public ConsoleMirror(string logFileName, Action <string> callback) { try { oldConsoleOut = Console.Out; mirrorWriter = new MirrorWriter(callback); Console.SetOut(mirrorWriter); if (!string.IsNullOrEmpty(logFileName)) { logFileStream = File.Open(logFileName, FileMode.Create, FileAccess.Write, FileShare.Read); logStreamWriter = new StreamWriter(logFileStream); logStreamWriter.AutoFlush = true; } } catch (Exception ex) { Console.WriteLine(ex.Message); } }
public ConsoleMirror(string logFileName, Action<string> callback) { try { oldConsoleOut = Console.Out; mirrorWriter = new MirrorWriter(callback); Console.SetOut(mirrorWriter); if (!string.IsNullOrEmpty(logFileName)) { logFileStream = File.Open(logFileName, FileMode.Create, FileAccess.Write, FileShare.Read); logStreamWriter = new StreamWriter(logFileStream); logStreamWriter.AutoFlush = true; } } catch (Exception ex) { Console.WriteLine(ex.Message); } }