mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 11:00:32 +00:00
fix(SWT): Improved logging
This commit is contained in:
parent
d8ad113212
commit
6fad347bc0
@ -101,7 +101,7 @@ void ConnectAndReceiveLoop(Uri serverAddress)
|
||||
ReceiveLoop.Loop(config);
|
||||
}
|
||||
catch (ThreadInterruptedException e) { Log.InfoException(e); }
|
||||
catch (ThreadAbortException e) { Log.InfoException(e); }
|
||||
catch (ThreadAbortException e) { Log.Error("[SWT-WebSocketClientStandAlone]: Thread Abort Exception"); }
|
||||
catch (Exception e) { Log.Exception(e); }
|
||||
finally
|
||||
{
|
||||
|
@ -138,13 +138,13 @@ public static void Verbose(string msg)
|
||||
public static void Verbose<T>(string msg, T arg1)
|
||||
{
|
||||
if (minLogLevel > Levels.Verbose) return;
|
||||
Verbose($"{msg} {arg1}");
|
||||
Verbose(String.Format(msg, arg1));
|
||||
}
|
||||
|
||||
public static void Verbose<T1, T2>(string msg, T1 arg1, T2 arg2)
|
||||
{
|
||||
if (minLogLevel > Levels.Verbose) return;
|
||||
Verbose($"{msg} {arg1} {arg2}");
|
||||
Verbose(String.Format(msg, arg1, arg2));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -168,13 +168,13 @@ static void Info(string msg, ConsoleColor consoleColor = ConsoleColor.Cyan)
|
||||
public static void Info<T>(string msg, T arg1, ConsoleColor consoleColor = ConsoleColor.Cyan)
|
||||
{
|
||||
if (minLogLevel > Levels.Info) return;
|
||||
Info($"{msg} {arg1}", consoleColor);
|
||||
Info(String.Format(msg, arg1), consoleColor);
|
||||
}
|
||||
|
||||
public static void Info<T1, T2>(string msg, T1 arg1, T2 arg2, ConsoleColor consoleColor = ConsoleColor.Cyan)
|
||||
{
|
||||
if (minLogLevel > Levels.Info) return;
|
||||
Info($"{msg} {arg1} {arg2}", consoleColor);
|
||||
Info(String.Format(msg, arg1, arg2), consoleColor);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -218,7 +218,7 @@ public static void Warn(string msg)
|
||||
public static void Warn<T>(string msg, T arg1)
|
||||
{
|
||||
if (minLogLevel > Levels.Warn) return;
|
||||
Warn($"{msg} {arg1}");
|
||||
Warn(String.Format(msg, arg1));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -243,19 +243,19 @@ public static void Error(string msg)
|
||||
public static void Error<T>(string msg, T arg1)
|
||||
{
|
||||
if (minLogLevel > Levels.Error) return;
|
||||
Error($"{msg} {arg1}");
|
||||
Error(String.Format(msg, arg1));
|
||||
}
|
||||
|
||||
public static void Error<T1, T2>(string msg, T1 arg1, T2 arg2)
|
||||
{
|
||||
if (minLogLevel > Levels.Error) return;
|
||||
Error($"{msg} {arg1} {arg2}");
|
||||
Error(String.Format(msg, arg1, arg2));
|
||||
}
|
||||
|
||||
public static void Error<T1, T2, T3>(string msg, T1 arg1, T2 arg2, T3 arg3)
|
||||
{
|
||||
if (minLogLevel > Levels.Error) return;
|
||||
Error($"{msg} {arg1} {arg2} {arg3}");
|
||||
Error(String.Format(msg, arg1, arg2, arg3));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -20,7 +20,7 @@ public static int Read(Stream stream, byte[] outBuffer, int outOffset, int lengt
|
||||
{
|
||||
int read = stream.Read(outBuffer, outOffset + received, length - received);
|
||||
if (read == 0)
|
||||
throw new ReadHelperException("returned 0");
|
||||
throw new ReadHelperException("[SWT-ReadHelper]: Read returned 0");
|
||||
|
||||
received += read;
|
||||
}
|
||||
@ -35,7 +35,7 @@ public static int Read(Stream stream, byte[] outBuffer, int outOffset, int lengt
|
||||
}
|
||||
|
||||
if (received != length)
|
||||
throw new ReadHelperException("returned not equal to length");
|
||||
throw new ReadHelperException("[SWT-ReadHelper]: received not equal to length");
|
||||
|
||||
return outOffset + received;
|
||||
}
|
||||
|
@ -72,12 +72,9 @@ public static void Loop(Config config)
|
||||
}
|
||||
}
|
||||
catch (ThreadInterruptedException e) { Log.InfoException(e); }
|
||||
catch (ThreadAbortException e) { Log.InfoException(e); }
|
||||
catch (ThreadAbortException e) { Log.Error("[SWT-ReceiveLoop]: Thread Abort Exception"); }
|
||||
catch (ObjectDisposedException e) { Log.InfoException(e); }
|
||||
catch (ReadHelperException e)
|
||||
{
|
||||
Log.InfoException(e);
|
||||
}
|
||||
catch (ReadHelperException e) { Log.InfoException(e); }
|
||||
catch (SocketException e)
|
||||
{
|
||||
// this could happen if wss client closes stream
|
||||
|
@ -116,11 +116,8 @@ public static void Loop(Config config)
|
||||
Log.Verbose("[SWT-SendLoop]: {0} Not Connected", conn);
|
||||
}
|
||||
catch (ThreadInterruptedException e) { Log.InfoException(e); }
|
||||
catch (ThreadAbortException e) { Log.InfoException(e); }
|
||||
catch (Exception e)
|
||||
{
|
||||
Log.Exception(e);
|
||||
}
|
||||
catch (ThreadAbortException e) { Log.Error("[SWT-SendLoop]: Thread Abort Exception"); }
|
||||
catch (Exception e) { Log.Exception(e); }
|
||||
finally
|
||||
{
|
||||
Profiler.EndThreadProfiling();
|
||||
|
@ -97,7 +97,7 @@ void acceptLoop()
|
||||
}
|
||||
}
|
||||
catch (ThreadInterruptedException e) { Log.InfoException(e); }
|
||||
catch (ThreadAbortException e) { Log.InfoException(e); }
|
||||
catch (ThreadAbortException e) { Log.Error("[SWT-WebSocketServer]: Thread Abort Exception"); }
|
||||
catch (Exception e) { Log.Exception(e); }
|
||||
}
|
||||
|
||||
@ -160,18 +160,9 @@ void HandshakeAndReceiveLoop(Connection conn)
|
||||
|
||||
ReceiveLoop.Loop(receiveConfig);
|
||||
}
|
||||
catch (ThreadInterruptedException e)
|
||||
{
|
||||
Log.Error("[SWT-WebSocketServer]: Handshake ThreadInterruptedException {0}", e.Message);
|
||||
}
|
||||
catch (ThreadAbortException e)
|
||||
{
|
||||
Log.Error("[SWT-WebSocketServer]: Handshake ThreadAbortException {0}", e.Message);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Log.Error("[SWT-WebSocketServer]: Handshake Exception {0}", e.Message);
|
||||
}
|
||||
catch (ThreadInterruptedException e) { Log.InfoException(e); }
|
||||
catch (ThreadAbortException e) { Log.Error("[SWT-WebSocketServer]: Thread Abort Exception"); }
|
||||
catch (Exception e) { Log.Exception(e); }
|
||||
finally
|
||||
{
|
||||
// close here in case connect fails
|
||||
|
Loading…
Reference in New Issue
Block a user