using System; using System.Collections.Concurrent; namespace ZeroLevel.Logging { internal sealed class NoLimitedLogMessageBuffer : ILogMessageBuffer { private readonly BlockingCollection> _messageQueue = new BlockingCollection>(); private bool _isDisposed = false; public long Count { get { if (_isDisposed || _messageQueue.IsCompleted) return 0; return _messageQueue.Count; } } public void Dispose() { if (!_isDisposed) { _isDisposed = true; _messageQueue.Dispose(); } } public void Push(LogLevel level, string message) { if (_isDisposed) return; _messageQueue.Add(new Tuple(level, message)); } public Tuple Take() { return _messageQueue.Take(); } } }