Skip to content

Commit d051233

Browse files
committed
feat: Added LogLevels and automatic log hooks into UnityEngine
1 parent 29f0904 commit d051233

File tree

11 files changed

+184
-76
lines changed

11 files changed

+184
-76
lines changed

Ruffles/Channeling/Channels/ReliableChannel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ public HeapMemory[] CreateOutgoingMessage(ArraySegment<byte> payload, out bool d
114114
{
115115
if (payload.Count > config.MaxMessageSize)
116116
{
117-
Logging.Error("Tried to send message that was too large. Use a fragmented channel instead. [Size=" + payload.Count + "] [MaxMessageSize=" + config.MaxFragments + "]");
117+
if (Logging.CurrentLogLevel <= LogLevel.Error) Logging.LogError("Tried to send message that was too large. Use a fragmented channel instead. [Size=" + payload.Count + "] [MaxMessageSize=" + config.MaxFragments + "]");
118118
dealloc = false;
119119
return null;
120120
}

Ruffles/Channeling/Channels/ReliableSequencedChannel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ public HeapMemory[] CreateOutgoingMessage(ArraySegment<byte> payload, out bool d
154154
{
155155
if (payload.Count > config.MaxMessageSize)
156156
{
157-
Logging.Error("Tried to send message that was too large. Use a fragmented channel instead. [Size=" + payload.Count + "] [MaxMessageSize=" + config.MaxFragments + "]");
157+
if (Logging.CurrentLogLevel <= LogLevel.Error) Logging.LogError("Tried to send message that was too large. Use a fragmented channel instead. [Size=" + payload.Count + "] [MaxMessageSize=" + config.MaxFragments + "]");
158158
dealloc = false;
159159
return null;
160160
}

Ruffles/Channeling/Channels/ReliableSequencedFragmentedChannel.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ public HeapMemory HandlePoll()
269269

270270
if (fragment > config.MaxFragments)
271271
{
272-
Logging.Error("FragmentId was too large. [FragmentId=" + fragment + "] [Config.MaxFragments=" + config.MaxFragments + "]. The fragment was silently dropped, expect a timeout.");
272+
if (Logging.CurrentLogLevel <= LogLevel.Error) Logging.LogError("FragmentId was too large. [FragmentId=" + fragment + "] [Config.MaxFragments=" + config.MaxFragments + "]. The fragment was silently dropped, expect a timeout.");
273273
hasMore = false;
274274
return null;
275275
}
@@ -377,7 +377,7 @@ public HeapMemory[] CreateOutgoingMessage(ArraySegment<byte> payload, out bool d
377377

378378
if (fragmentsRequired > config.MaxFragments)
379379
{
380-
Logging.Error("Tried to create message that was too large. [Size=" + payload.Count + "] [FragmentsRequired=" + fragmentsRequired + "] [Config.MaxFragments=" + config.MaxFragments + "]");
380+
if (Logging.CurrentLogLevel <= LogLevel.Error) Logging.LogError("Tried to create message that was too large. [Size=" + payload.Count + "] [FragmentsRequired=" + fragmentsRequired + "] [Config.MaxFragments=" + config.MaxFragments + "]");
381381
dealloc = false;
382382
return null;
383383
}

Ruffles/Channeling/Channels/UnreliableChannel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public HeapMemory[] CreateOutgoingMessage(ArraySegment<byte> payload, out bool d
3737
{
3838
if (payload.Count > config.MaxMessageSize)
3939
{
40-
Logging.Error("Tried to send message that was too large. Use a fragmented channel instead. [Size=" + payload.Count + "] [MaxMessageSize=" + config.MaxFragments + "]");
40+
if (Logging.CurrentLogLevel <= LogLevel.Error) Logging.LogError("Tried to send message that was too large. Use a fragmented channel instead. [Size=" + payload.Count + "] [MaxMessageSize=" + config.MaxFragments + "]");
4141
dealloc = false;
4242
return null;
4343
}

Ruffles/Channeling/Channels/UnreliableRawChannel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public HeapMemory[] CreateOutgoingMessage(ArraySegment<byte> payload, out bool d
2929
{
3030
if (payload.Count > config.MaxMessageSize)
3131
{
32-
Logging.Error("Tried to send message that was too large. Use a fragmented channel instead. [Size=" + payload.Count + "] [MaxMessageSize=" + config.MaxFragments + "]");
32+
if (Logging.CurrentLogLevel <= LogLevel.Error) Logging.LogError("Tried to send message that was too large. Use a fragmented channel instead. [Size=" + payload.Count + "] [MaxMessageSize=" + config.MaxFragments + "]");
3333
dealloc = false;
3434
return null;
3535
}

Ruffles/Channeling/Channels/UnreliableSequencedChannel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public HeapMemory[] CreateOutgoingMessage(ArraySegment<byte> payload, out bool d
3535
{
3636
if (payload.Count > config.MaxMessageSize)
3737
{
38-
Logging.Error("Tried to send message that was too large. Use a fragmented channel instead. [Size=" + payload.Count + "] [MaxMessageSize=" + config.MaxFragments + "]");
38+
if (Logging.CurrentLogLevel <= LogLevel.Error) Logging.LogError("Tried to send message that was too large. Use a fragmented channel instead. [Size=" + payload.Count + "] [MaxMessageSize=" + config.MaxFragments + "]");
3939
dealloc = false;
4040
return null;
4141
}

Ruffles/Configuration/SocketConfig.cs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,7 @@ namespace Ruffles.Configuration
77
{
88
public class SocketConfig
99
{
10-
// Random
11-
/// <summary>
12-
/// Whether or not to use verbose info logging. This can cause tons of garbage allocation.
13-
/// </summary>
14-
public bool UseVerboseInfoLogging = false;
10+
// General
1511
/// <summary>
1612
/// Whether or not to allow polling of the socket. This will require all messages to be processed in a queue.
1713
/// </summary>

0 commit comments

Comments
 (0)