Beispiel #1
0
        public void LogAsync(string message)
        {
            System.Windows.Application.Current.Dispatcher?.InvokeAsync(() =>
            {
                var messageItem = LoggingMessageItem.CreateMessage(message);
                _messageList.Add(messageItem);
                OnNewMessagePushed(messageItem);

                if (_messageList.Count > MaxCount)
                {
                    var numToRemove = (int)(MaxCount * PercentToRemove);
                    _messageList    = _messageList.Skip(numToRemove).ToList();
                    OnMessageRemoved(numToRemove);
                }
                OnPropertyChanged(nameof(Count));

                if (ShouldSerialize)
                {
                    messageItem.WriteLineToFile(_serializationDir, _fileName);
                }
            });
        }
Beispiel #2
0
 protected virtual void OnNewMessagePushed(LoggingMessageItem obj)
 {
     NewMessagePushed?.Invoke(obj);
 }