{
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}");
+ }
}
}
}
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) =>
{