Skip to content

Commit

Permalink
feat: NetworkConnection to client and server use logger framework
Browse files Browse the repository at this point in the history
  • Loading branch information
paulpach committed Apr 26, 2020
1 parent ec319a1 commit 72154f1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion Assets/Mirror/Runtime/NetworkConnectionToClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ namespace Mirror
{
public class NetworkConnectionToClient : NetworkConnection
{
static readonly ILogger logger = LogFactory.GetLogger<NetworkConnectionToClient>();

public NetworkConnectionToClient(int networkConnectionId) : base(networkConnectionId) { }

public override string address => Transport.activeTransport.ServerGetClientAddress(connectionId);
Expand All @@ -21,7 +23,7 @@ public class NetworkConnectionToClient : NetworkConnection

internal override bool Send(ArraySegment<byte> segment, int channelId = Channels.DefaultReliable)
{
if (logNetworkMessages) Debug.Log("ConnectionSend " + this + " bytes:" + BitConverter.ToString(segment.Array, segment.Offset, segment.Count));
if (logger.LogEnabled()) logger.Log("ConnectionSend " + this + " bytes:" + BitConverter.ToString(segment.Array, segment.Offset, segment.Count));

// validate packet size first.
if (ValidatePacketSize(segment, channelId))
Expand Down
4 changes: 3 additions & 1 deletion Assets/Mirror/Runtime/NetworkConnectionToServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@ namespace Mirror
{
public class NetworkConnectionToServer : NetworkConnection
{
static readonly ILogger logger = LogFactory.GetLogger<NetworkConnectionToServer>();

public override string address => "";

internal override bool Send(ArraySegment<byte> segment, int channelId = Channels.DefaultReliable)
{
if (logNetworkMessages) Debug.Log("ConnectionSend " + this + " bytes:" + BitConverter.ToString(segment.Array, segment.Offset, segment.Count));
if (logger.LogEnabled()) logger.Log("ConnectionSend " + this + " bytes:" + BitConverter.ToString(segment.Array, segment.Offset, segment.Count));

// validate packet size first.
if (ValidatePacketSize(segment, channelId))
Expand Down

0 comments on commit 72154f1

Please sign in to comment.