You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Zero/ZeroLevel/Services/Logging/NoLimitedLogMessageBuffer.cs

44 lines
1.0 KiB

6 years ago
using System;
using System.Collections.Concurrent;
5 years ago
namespace ZeroLevel.Logging
6 years ago
{
5 years ago
internal sealed class NoLimitedLogMessageBuffer
: ILogMessageBuffer
6 years ago
{
private readonly BlockingCollection<Tuple<LogLevel, string>> _messageQueue =
new BlockingCollection<Tuple<LogLevel, string>>();
6 years ago
private bool _isDisposed = false;
public long Count
{
get
{
if (_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<LogLevel, string>(level, message));
}
public Tuple<LogLevel, string> Take()
{
return _messageQueue.Take();
}
}
}

Powered by TurnKey Linux.