From 6ed5283bc06a62f38eb517e67b975832b603bf61 Mon Sep 17 00:00:00 2001 From: Jeff Ames Date: Tue, 5 Feb 2008 19:44:27 +0000 Subject: Converted logging to use log4net. Changed LogBase to ConsoleBase, which handles console I/O. This is mostly an in-place conversion, so lots of refactoring can still be done. --- OpenSim/Region/ClientStack/UDPServer.cs | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) (limited to 'OpenSim/Region/ClientStack/UDPServer.cs') diff --git a/OpenSim/Region/ClientStack/UDPServer.cs b/OpenSim/Region/ClientStack/UDPServer.cs index 3e2b536..f9918ff 100644 --- a/OpenSim/Region/ClientStack/UDPServer.cs +++ b/OpenSim/Region/ClientStack/UDPServer.cs @@ -39,6 +39,8 @@ namespace OpenSim.Region.ClientStack { public class UDPServer : ClientStackNetworkHandler { + private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); + protected Dictionary clientCircuits = new Dictionary(); public Dictionary clientCircuits_reverse = new Dictionary(); public Socket Server; @@ -56,7 +58,6 @@ namespace OpenSim.Region.ClientStack protected IPAddress listenIP = IPAddress.Parse("0.0.0.0"); protected IScene m_localScene; protected AssetCache m_assetCache; - protected LogBase m_log; protected AgentCircuitManager m_authenticateSessionsClass; public PacketServer PacketServer @@ -84,13 +85,12 @@ namespace OpenSim.Region.ClientStack { } - public UDPServer(IPAddress _listenIP, ref uint port, bool allow_alternate_port, AssetCache assetCache, LogBase console, AgentCircuitManager authenticateClass) + public UDPServer(IPAddress _listenIP, ref uint port, bool allow_alternate_port, AssetCache assetCache, AgentCircuitManager authenticateClass) { listenIP = _listenIP; listenPort = port; Allow_Alternate_Port = allow_alternate_port; m_assetCache = assetCache; - m_log = console; m_authenticateSessionsClass = authenticateClass; CreatePacketServer(); @@ -121,7 +121,7 @@ namespace OpenSim.Region.ClientStack { // TODO : Actually only handle those states that we have control over, re-throw everything else, // TODO: implement cases as we encounter them. - //m_log.Error("UDPSERVER", "Connection Error! - " + e.ToString()); + //m_log.Error("[UDPSERVER]: Connection Error! - " + e.ToString()); switch (e.SocketErrorCode) { case SocketError.AlreadyInProgress: @@ -134,7 +134,7 @@ namespace OpenSim.Region.ClientStack } catch (Exception a) { - MainLog.Instance.Verbose("UDPSERVER", a.ToString()); + m_log.Info("[UDPSERVER]: " + a.ToString()); } try { @@ -159,7 +159,7 @@ namespace OpenSim.Region.ClientStack } catch (Exception) { - //MainLog.Instance.Verbose("UDPSERVER", a.ToString()); + //m_log.Info("[UDPSERVER]" + a.ToString()); } try { @@ -191,8 +191,7 @@ namespace OpenSim.Region.ClientStack } catch (ObjectDisposedException) { - - //MainLog.Instance.Debug("UDPSERVER", e.ToString()); + //m_log.Debug("[UDPSERVER]: " + e.ToString()); return; } @@ -214,20 +213,20 @@ namespace OpenSim.Region.ClientStack if (clientCircuits.TryGetValue(epSender, out circuit)) { //if so then send packet to the packetserver - //MainLog.Instance.Warn("UDPSERVER", "ALREADY HAVE Circuit!"); + //m_log.Warn("[UDPSERVER]: ALREADY HAVE Circuit!"); m_packetServer.InPacket(circuit, packet); } else if (packet.Type == PacketType.UseCircuitCode) { // new client - MainLog.Instance.Debug("UDPSERVER", "Adding New Client"); + m_log.Debug("[UDPSERVER]: Adding New Client"); AddNewClient(packet); } else { // invalid client //CFK: This message seems to have served its usefullness as of 12-15 so I am commenting it out for now - //m_log.Warn("UDPSERVER", "Got a packet from an invalid client - " + packet.ToString()); + //m_log.Warn("[UDPSERVER]: Got a packet from an invalid client - " + packet.ToString()); } } @@ -255,12 +254,11 @@ namespace OpenSim.Region.ClientStack public void ServerListener() { - uint newPort = listenPort; for (uint i = 0; i < 20; i++) { newPort = listenPort + i; - m_log.Verbose("SERVER", "Opening UDP socket on " + listenIP.ToString() + " " + newPort + ".");// Allow alternate ports: " + Allow_Alternate_Port.ToString()); + m_log.Info("[SERVER]: Opening UDP socket on " + listenIP.ToString() + " " + newPort + ".");// Allow alternate ports: " + Allow_Alternate_Port.ToString()); try { ServerIncoming = new IPEndPoint(listenIP, (int) newPort); @@ -276,19 +274,19 @@ namespace OpenSim.Region.ClientStack throw (ex); // We are looking for alternate ports! - m_log.Verbose("SERVER", "UDP socket on " + listenIP.ToString() + " " + listenPort.ToString() + " is not available, trying next."); + m_log.Info("[SERVER]: UDP socket on " + listenIP.ToString() + " " + listenPort.ToString() + " is not available, trying next."); } System.Threading.Thread.Sleep(100); // Wait before we retry socket } - m_log.Verbose("SERVER", "UDP socket bound, getting ready to listen"); + m_log.Info("[SERVER]: UDP socket bound, getting ready to listen"); ipeSender = new IPEndPoint(listenIP, 0); epSender = (EndPoint) ipeSender; ReceivedData = new AsyncCallback(OnReceivedData); Server.BeginReceiveFrom(RecvBuffer, 0, RecvBuffer.Length, SocketFlags.None, ref epSender, ReceivedData, null); - m_log.Status("SERVER", "Listening on port " + newPort); + m_log.Info("[SERVER]: Listening on port " + newPort); } public virtual void RegisterPacketServer(PacketServer server) -- cgit v1.1