예제 #1
0
 public void Log(CLog.LogData logData)
 {
     lock (this.mLogLock)
     {
         this.mWaitingLogQueue.Enqueue(logData);
         Monitor.Pulse(this.mLogLock);
     }
 }
예제 #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 <CLog.LogData> tmpQueue = this.mWritingLogQueue;
                 this.mWritingLogQueue = this.mWaitingLogQueue;
                 this.mWaitingLogQueue = tmpQueue;
             }
         }
         else
         {
             while (this.mWritingLogQueue.Count > 0)
             {
                 CLog.LogData log = this.mWritingLogQueue.Dequeue();
                 if (log.Level == CLog.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);
                 }
             }
         }
     }
 }