コード例 #1
0
        public void Dispose()
        {
            Console.SetOut(oldConsoleOut);
            mirrorWriter = null;

            logStreamWriter.Flush();
            logStreamWriter = null;

            logFileStream.Flush();
            logFileStream.Close();
            logFileStream = null;
        }
コード例 #2
0
 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);
     }
 }
コード例 #3
0
        public void Dispose()
        {
            Console.SetOut(oldConsoleOut);
            mirrorWriter = null;

            logStreamWriter.Flush();
            logStreamWriter = null;

            logFileStream.Flush();
            logFileStream.Close();
            logFileStream = null;
        }
コード例 #4
0
 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);
     }
 }