From 8763f3a99ed7c0651e94a1cb13525351adbc7851 Mon Sep 17 00:00:00 2001 From: Matthew Endsley Date: Thu, 4 Feb 2021 13:52:00 -0800 Subject: [PATCH] Add prefix string to TestLogger --- Hazel.UnitTests/TestLogger.cs | 25 +++++++++++++++++-- .../ThreadLimitedUdpConnectionTests.cs | 4 +-- 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/Hazel.UnitTests/TestLogger.cs b/Hazel.UnitTests/TestLogger.cs index 6b2c570..2e76e8d 100644 --- a/Hazel.UnitTests/TestLogger.cs +++ b/Hazel.UnitTests/TestLogger.cs @@ -8,14 +8,35 @@ namespace Hazel.UnitTests { public class TestLogger : ILogger { + private readonly string prefix; + + public TestLogger(string prefix = "") + { + this.prefix = prefix; + } + public void WriteError(string msg) { - Console.WriteLine($"[ERROR] {msg}"); + if (string.IsNullOrEmpty(this.prefix)) + { + Console.WriteLine($"[ERROR] {msg}"); + } + else + { + Console.WriteLine($"[{this.prefix}][ERROR] {msg}"); + } } public void WriteInfo(string msg) { - Console.WriteLine($"[INFO] {msg}"); + if (string.IsNullOrEmpty(this.prefix)) + { + Console.WriteLine($"[INFO] {msg}"); + } + else + { + Console.WriteLine($"[{this.prefix}][INFO] {msg}"); + } } } } diff --git a/Hazel.UnitTests/ThreadLimitedUdpConnectionTests.cs b/Hazel.UnitTests/ThreadLimitedUdpConnectionTests.cs index 30905d4..3f77275 100644 --- a/Hazel.UnitTests/ThreadLimitedUdpConnectionTests.cs +++ b/Hazel.UnitTests/ThreadLimitedUdpConnectionTests.cs @@ -36,8 +36,8 @@ namespace Hazel.UnitTests bool serverDisconnected = false; bool clientDisconnected = false; - using (ThreadLimitedUdpConnectionListener listener = this.CreateListener(2, new IPEndPoint(IPAddress.Any, 4296), new TestLogger())) - using (UdpConnection connection = this.CreateConnection(ep, new TestLogger())) + using (ThreadLimitedUdpConnectionListener listener = this.CreateListener(2, new IPEndPoint(IPAddress.Any, 4296), new TestLogger("SERVER"))) + using (UdpConnection connection = this.CreateConnection(ep, new TestLogger("CLIENT"))) { listener.NewConnection += (evt) => { -- 2.39.5