public override async Task WriteMessageAsync(Message message) { // If message group is empty or the given message can be grouped, buffer the given message if (!_messageGroupBuffer.Any() || MessageGroup.CanGroup(_messageGroupBuffer.Last(), message)) { _messageGroupBuffer.Add(message); } // Otherwise, flush the group and render messages else { await RenderCurrentMessageGroupAsync(); _messageGroupBuffer.Clear(); _messageGroupBuffer.Add(message); } // Increment message count _messageCount++; }