コード例 #1
0
        public void Flush()
        {
            lock (this)
            {
                if (_messageBuffer.Length == 0)
                {
                    return;
                }

                var fileName = GetFileName();

                if (_fileWriter != null && !_fileWriter.IsValid(fileName))
                {
                    InnerLoggerFileWriter.RemoveInstance(_fileWriter);
                    _fileWriter = null;
                }

                if (_fileWriter == null)
                {
                    _fileWriter = InnerLoggerFileWriter.GetInstance(fileName);
                }

                if (!_fileWriter.Write(_messageBuffer))
                {
                    return;
                }
                _messageBuffer.Length = 0;
                _sendTimer            = -1;
            }
        }
コード例 #2
0
 public void Close()
 {
     Flush();
     if (_fileWriter == null)
     {
         return;
     }
     InnerLoggerFileWriter.RemoveInstance(_fileWriter);
     _fileWriter = null;
 }
コード例 #3
0
 public static void RemoveInstance(InnerLoggerFileWriter writer)
 {
     lock (Instances)
     {
         writer._refCount -= 1;
         if (writer._refCount != 0)
         {
             return;
         }
         writer.Close();
         Instances.Remove(writer._fileName);
     }
 }