Esempio n. 1
0
 public void Log(LogTool.LogData logData)
 {
     lock (this.mLogLock)
     {
         this.mWaitingLogQueue.Enqueue(logData);
         Monitor.Pulse(this.mLogLock);
     }
 }
Esempio n. 2
0
 void WriteLog()
 {
     while (this.mIsRunning)
     {
         if (this.mWritingLogQueue.Count == 0)
         {
             lock (this.mLogLock)
             {
                 while (this.mWaitingLogQueue.Count == 0)
                 {
                     Monitor.Wait(this.mLogLock);
                 }
                 Queue <LogTool.LogData> tmpQueue = this.mWritingLogQueue;
                 this.mWritingLogQueue = this.mWaitingLogQueue;
                 this.mWaitingLogQueue = tmpQueue;
             }
         }
         else
         {
             while (this.mWritingLogQueue.Count > 0)
             {
                 LogTool.LogData log = this.mWritingLogQueue.Dequeue();
                 if (log.Level == LogTool.LogLevel.ERROR)
                 {
                     this.mLogWriter.WriteLine("---------------------------------------------------------------------------------------------------------------------");
                     this.mLogWriter.WriteLine(System.DateTime.Now.ToString() + "\t" + log.Log + "\n");
                     this.mLogWriter.WriteLine(log.Track);
                     this.mLogWriter.WriteLine("---------------------------------------------------------------------------------------------------------------------");
                 }
                 else
                 {
                     this.mLogWriter.WriteLine(System.DateTime.Now.ToString() + "\t" + log.Log);
                 }
             }
         }
     }
 }