Skip to content

Commit

Permalink
feat: Added LogLevels and automatic log hooks into UnityEngine
Browse files Browse the repository at this point in the history
  • Loading branch information
TwoTenPvP committed Sep 4, 2019
1 parent 29f0904 commit d051233
Show file tree
Hide file tree
Showing 11 changed files with 184 additions and 76 deletions.
2 changes: 1 addition & 1 deletion Ruffles/Channeling/Channels/ReliableChannel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ public HeapMemory[] CreateOutgoingMessage(ArraySegment<byte> payload, out bool d
{
if (payload.Count > config.MaxMessageSize)
{
Logging.Error("Tried to send message that was too large. Use a fragmented channel instead. [Size=" + payload.Count + "] [MaxMessageSize=" + config.MaxFragments + "]");
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 + "]");
dealloc = false;
return null;
}
Expand Down
2 changes: 1 addition & 1 deletion Ruffles/Channeling/Channels/ReliableSequencedChannel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ public HeapMemory[] CreateOutgoingMessage(ArraySegment<byte> payload, out bool d
{
if (payload.Count > config.MaxMessageSize)
{
Logging.Error("Tried to send message that was too large. Use a fragmented channel instead. [Size=" + payload.Count + "] [MaxMessageSize=" + config.MaxFragments + "]");
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 + "]");
dealloc = false;
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ public HeapMemory HandlePoll()

if (fragment > config.MaxFragments)
{
Logging.Error("FragmentId was too large. [FragmentId=" + fragment + "] [Config.MaxFragments=" + config.MaxFragments + "]. The fragment was silently dropped, expect a timeout.");
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.");
hasMore = false;
return null;
}
Expand Down Expand Up @@ -377,7 +377,7 @@ public HeapMemory[] CreateOutgoingMessage(ArraySegment<byte> payload, out bool d

if (fragmentsRequired > config.MaxFragments)
{
Logging.Error("Tried to create message that was too large. [Size=" + payload.Count + "] [FragmentsRequired=" + fragmentsRequired + "] [Config.MaxFragments=" + config.MaxFragments + "]");
if (Logging.CurrentLogLevel <= LogLevel.Error) Logging.LogError("Tried to create message that was too large. [Size=" + payload.Count + "] [FragmentsRequired=" + fragmentsRequired + "] [Config.MaxFragments=" + config.MaxFragments + "]");
dealloc = false;
return null;
}
Expand Down
2 changes: 1 addition & 1 deletion Ruffles/Channeling/Channels/UnreliableChannel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public HeapMemory[] CreateOutgoingMessage(ArraySegment<byte> payload, out bool d
{
if (payload.Count > config.MaxMessageSize)
{
Logging.Error("Tried to send message that was too large. Use a fragmented channel instead. [Size=" + payload.Count + "] [MaxMessageSize=" + config.MaxFragments + "]");
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 + "]");
dealloc = false;
return null;
}
Expand Down
2 changes: 1 addition & 1 deletion Ruffles/Channeling/Channels/UnreliableRawChannel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public HeapMemory[] CreateOutgoingMessage(ArraySegment<byte> payload, out bool d
{
if (payload.Count > config.MaxMessageSize)
{
Logging.Error("Tried to send message that was too large. Use a fragmented channel instead. [Size=" + payload.Count + "] [MaxMessageSize=" + config.MaxFragments + "]");
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 + "]");
dealloc = false;
return null;
}
Expand Down
2 changes: 1 addition & 1 deletion Ruffles/Channeling/Channels/UnreliableSequencedChannel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public HeapMemory[] CreateOutgoingMessage(ArraySegment<byte> payload, out bool d
{
if (payload.Count > config.MaxMessageSize)
{
Logging.Error("Tried to send message that was too large. Use a fragmented channel instead. [Size=" + payload.Count + "] [MaxMessageSize=" + config.MaxFragments + "]");
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 + "]");
dealloc = false;
return null;
}
Expand Down
6 changes: 1 addition & 5 deletions Ruffles/Configuration/SocketConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,7 @@ namespace Ruffles.Configuration
{
public class SocketConfig
{
// Random
/// <summary>
/// Whether or not to use verbose info logging. This can cause tons of garbage allocation.
/// </summary>
public bool UseVerboseInfoLogging = false;
// General
/// <summary>
/// Whether or not to allow polling of the socket. This will require all messages to be processed in a queue.
/// </summary>
Expand Down
Loading

0 comments on commit d051233

Please sign in to comment.