Skip to content

Commit acf5f4d

Browse files
author
giordanol
committed
Enhanced logging
1 parent 380d06a commit acf5f4d

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/Publisher/Program.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
if (line != null && int.TryParse(line, out var result))
2323
{
2424
var cts = new CancellationTokenSource();
25-
25+
var messages = result / 3;
2626
var ct = cts.Token;
2727
var connection = new NpgsqlConnection(Settings.ConnectionString);
2828
await using var connection1 = connection.ConfigureAwait(false);
@@ -36,6 +36,9 @@
3636
1 => new UserDeleted(Guid.NewGuid()),
3737
_ => new UserModified(Guid.NewGuid())
3838
});
39+
await Console.Out.WriteLineAsync($"Publishing {messages + ((result % 3 > 0) ? 1 : 0)} {nameof(UserCreated)}");
40+
await Console.Out.WriteLineAsync($"Publishing {messages + ((result % 3 > 1) ? 1 : 0)} {nameof(UserDeleted)}");
41+
await Console.Out.WriteLineAsync($"Publishing {messages} {nameof(UserModified)}");
3942
foreach (var @event in @events)
4043
{
4144
var transaction = await connection.BeginTransactionAsync(ct).ConfigureAwait(false);
@@ -63,6 +66,7 @@
6366
throw;
6467
}
6568
}
69+
await Console.Out.WriteLineAsync($"Published {result} messages!");
6670
}
6771
//use a batch command
6872
//{

0 commit comments

Comments
 (0)