]> git.deb.at Git - rhonda/impostor.hazel.git/commitdiff
Add prefix string to TestLogger
authorMatthew Endsley <mendsley@gmail.com>
Thu, 4 Feb 2021 21:52:00 +0000 (13:52 -0800)
committerMatthew Endsley <mendsley@gmail.com>
Thu, 4 Feb 2021 21:52:13 +0000 (13:52 -0800)
Hazel.UnitTests/TestLogger.cs
Hazel.UnitTests/ThreadLimitedUdpConnectionTests.cs

index 6b2c5705d48c523762decaac96e168b9c091a0d4..2e76e8db117cdaff6bb11b7520a70fc45672c6e1 100644 (file)
@@ -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}");
+            }
         }
     }
 }
index 30905d4129ff1f33be4b7bac6ffe2f45ad4f07de..3f77275c66682dcd97036fc609c5cfb48d12631b 100644 (file)
@@ -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) =>
                 {