예제 #1
0
        private void FileWrite(LogMessage msg)
        {
            try
            {
                if (_writer == null)
                {
                    FileOpen();
                }
                else
                {
                    //determine the log file is time sign
                    if (DateTime.Now >= _timeSign)
                    {
                        FileClose();
                        FileOpen();
                    }
                }

                var strArr = msg.Text.Split(new char[] { '\n' }, StringSplitOptions.RemoveEmptyEntries);
                foreach (var s in strArr)
                {
                    _writer.WriteLine(s);
                }
                _writer.Flush();
            }
            catch (Exception e)
            {
                Console.Out.Write(e);
            }
        }
예제 #2
0
 /// <summary>
 /// 入队
 /// </summary>
 public void Write(LogMessage msg)
 {
     if (msg != null)
     {
         lock (_lockObjeck)
         {
             _logMessages.Enqueue(msg);
             _semaphore.Release();
         }
     }
 }