Skip to content

Commit bbaf437

Browse files
committed
fix: do not log when no event was published
1 parent a26969c commit bbaf437

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

src/Cnblogs.Architecture.Ddd.EventBus.Abstractions/PublishIntegrationEventHostedService.cs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,14 @@ protected override async Task ExecuteAsync(CancellationToken stoppingToken)
5050
await PublishEventAsync();
5151
watch.Stop();
5252
var afterCount = _eventBuffer.Count;
53-
_logger.LogInformation(
54-
"Published {PublishedEventCount} events in {Duration} ms, resting count: {RestingEventCount}",
55-
beforeCount - afterCount,
56-
watch.ElapsedMilliseconds,
57-
afterCount);
53+
if (afterCount - beforeCount > 0)
54+
{
55+
_logger.LogInformation(
56+
"Published {PublishedEventCount} events in {Duration} ms, resting count: {RestingEventCount}",
57+
beforeCount - afterCount,
58+
watch.ElapsedMilliseconds,
59+
afterCount);
60+
}
5861
}
5962
catch (Exception e)
6063
{

0 commit comments

Comments
 (0)