From: Matthew Endsley Date: Thu, 4 Feb 2021 21:52:00 +0000 (-0800) Subject: Add prefix string to TestLogger X-Git-Tag: 1.0.0~20^2^2~1 X-Git-Url: https://git.deb.at/?a=commitdiff_plain;h=8763f3a99ed7c0651e94a1cb13525351adbc7851;p=rhonda%2Fimpostor.hazel.git Add prefix string to TestLogger --- 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) => {