added nlog logging (todo: custom logger for packets)

This commit is contained in:
Tahir Akhlaq 2016-06-14 05:09:30 +01:00
parent c5516511b0
commit ed0a0a58f7
36 changed files with 5430 additions and 310 deletions

View file

@ -5,6 +5,7 @@ using System.Net.Sockets;
using System.Threading;
using FFXIVClassic_Lobby_Server.packets;
using FFXIVClassic.Common;
using NLog;
namespace FFXIVClassic_Lobby_Server
{
@ -25,7 +26,7 @@ namespace FFXIVClassic_Lobby_Server
private void socketCleanup()
{
Program.Log.Debug(String.Format("Cleanup thread started; it will run every {0} seconds.", CLEANUP_THREAD_SLEEP_TIME));
Program.Log.Info("Cleanup thread started; it will run every {0} seconds.", CLEANUP_THREAD_SLEEP_TIME);
while (!killCleanupThread)
{
int count = 0;
@ -40,7 +41,7 @@ namespace FFXIVClassic_Lobby_Server
}
}
if (count != 0)
Program.Log.Status(String.Format("{0} connections were cleaned up.", count));
Program.Log.Info("{0} connections were cleaned up.", count);
Thread.Sleep(CLEANUP_THREAD_SLEEP_TIME*1000);
}
}
@ -80,7 +81,7 @@ namespace FFXIVClassic_Lobby_Server
}
Console.ForegroundColor = ConsoleColor.White;
Program.Log.Debug(String.Format("Lobby Server has started @ {0}:{1}", (mServerSocket.LocalEndPoint as IPEndPoint).Address, (mServerSocket.LocalEndPoint as IPEndPoint).Port));
Program.Log.Debug("Lobby Server has started @ {0}:{1}", (mServerSocket.LocalEndPoint as IPEndPoint).Address, (mServerSocket.LocalEndPoint as IPEndPoint).Port);
Console.ForegroundColor = ConsoleColor.Gray;
mProcessor = new PacketProcessor();
@ -105,7 +106,7 @@ namespace FFXIVClassic_Lobby_Server
conn.socket.BeginReceive(conn.buffer, 0, conn.buffer.Length, SocketFlags.None, new AsyncCallback(receiveCallback), conn);
//Queue the accept of the next incomming connection
mServerSocket.BeginAccept(new AsyncCallback(acceptCallback), mServerSocket);
Program.Log.Status(String.Format("Connection {0}:{1} has connected.", (conn.socket.RemoteEndPoint as IPEndPoint).Address, (conn.socket.RemoteEndPoint as IPEndPoint).Port));
Program.Log.Info("Connection {0}:{1} has connected.", (conn.socket.RemoteEndPoint as IPEndPoint).Address, (conn.socket.RemoteEndPoint as IPEndPoint).Port);
}
catch (SocketException)
{
@ -179,7 +180,7 @@ namespace FFXIVClassic_Lobby_Server
}
else
{
Program.Log.Status(String.Format("{0} has disconnected.", conn.currentUserId == 0 ? conn.getAddress() : "User " + conn.currentUserId));
Program.Log.Info("{0} has disconnected.", conn.currentUserId == 0 ? conn.getAddress() : "User " + conn.currentUserId);
lock (mConnectionList)
{
@ -192,7 +193,7 @@ namespace FFXIVClassic_Lobby_Server
{
if (conn.socket != null)
{
Program.Log.Status(String.Format("{0} has disconnected.", conn.currentUserId == 0 ? conn.getAddress() : "User " + conn.currentUserId));
Program.Log.Info("{0} has disconnected.", conn.currentUserId == 0 ? conn.getAddress() : "User " + conn.currentUserId);
lock (mConnectionList)
{