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; } }
public void Close() { Flush(); if (_fileWriter == null) { return; } InnerLoggerFileWriter.RemoveInstance(_fileWriter); _fileWriter = null; }
public static void RemoveInstance(InnerLoggerFileWriter writer) { lock (Instances) { writer._refCount -= 1; if (writer._refCount != 0) { return; } writer.Close(); Instances.Remove(writer._fileName); } }