Skip to content

Commit

Permalink
perf: Added option to disable verbose logs
Browse files Browse the repository at this point in the history
  • Loading branch information
TwoTenPvP committed Sep 3, 2019
1 parent 4603b15 commit 61a7b44
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
8 changes: 7 additions & 1 deletion Ruffles/Configuration/SocketConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,13 @@
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;

// Connection
/// <summary>
/// The IPv4 address the socket will listen on.
Expand Down
7 changes: 5 additions & 2 deletions Ruffles/Core/RuffleSocket.cs
Original file line number Diff line number Diff line change
Expand Up @@ -665,8 +665,11 @@ internal void HandlePacket(ArraySegment<byte> payload, EndPoint endpoint)

// Unpack header, dont cast to MessageType enum for safety
HeaderPacker.Unpack(payload.Array[payload.Offset], out byte messageType, out bool fragmented);

Logging.Info("Unpacked packet. [MessageType=" + (MessageType)messageType + "] [Fragmented=" + fragmented + "]");

if (config.UseVerboseInfoLogging)
{
Logging.Info("Unpacked packet. [MessageType=" + (MessageType)messageType + "] [Fragmented=" + fragmented + "]");
}

switch (messageType)
{
Expand Down

0 comments on commit 61a7b44

Please sign in to comment.