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/ClientView.cs | 86 +++++++++++----------- OpenSim/Region/ClientStack/PacketQueue.cs | 10 ++- .../Region/ClientStack/RegionApplicationBase.cs | 19 +++-- OpenSim/Region/ClientStack/UDPServer.cs | 30 ++++---- 4 files changed, 75 insertions(+), 70 deletions(-) (limited to 'OpenSim/Region/ClientStack') diff --git a/OpenSim/Region/ClientStack/ClientView.cs b/OpenSim/Region/ClientStack/ClientView.cs index 5fdb9b3..10bf0d1 100644 --- a/OpenSim/Region/ClientStack/ClientView.cs +++ b/OpenSim/Region/ClientStack/ClientView.cs @@ -51,6 +51,8 @@ namespace OpenSim.Region.ClientStack /// public class ClientView : IClientAPI { + private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); + /* static variables */ public static TerrainManager TerrainManager; @@ -196,7 +198,7 @@ namespace OpenSim.Region.ClientStack // m_inventoryCache = inventoryCache; m_authenticateSessionsHandler = authenSessions; - MainLog.Instance.Verbose("CLIENT", "Started up new client thread to handle incoming request"); + m_log.Info("[CLIENT]: Started up new client thread to handle incoming request"); m_agentId = agentId; m_sessionId = sessionId; @@ -260,7 +262,7 @@ namespace OpenSim.Region.ClientStack public void Close(bool ShutdownCircult) { // Pull Client out of Region - MainLog.Instance.Verbose("CLIENT", "Close has been called"); + m_log.Info("[CLIENT]: Close has been called"); //raiseevent on the packet server to Shutdown the circuit if (ShutdownCircult) @@ -286,7 +288,7 @@ namespace OpenSim.Region.ClientStack public void Stop() { - MainLog.Instance.Verbose("BUG", "Stop called, please find out where and remove it"); + m_log.Info("[BUG]: Stop called, please find out where and remove it"); } #endregion @@ -378,7 +380,7 @@ namespace OpenSim.Region.ClientStack protected virtual void ClientLoop() { - MainLog.Instance.Verbose("CLIENT", "Entered loop"); + m_log.Info("[CLIENT]: Entered loop"); while (true) { QueItem nextPacket = m_packetQueue.Dequeue(); @@ -445,7 +447,7 @@ namespace OpenSim.Region.ClientStack m_clientPingTimer.Elapsed += new ElapsedEventHandler(CheckClientConnectivity); m_clientPingTimer.Enabled = true; - MainLog.Instance.Verbose("CLIENT", "Adding viewer agent to scene"); + m_log.Info("[CLIENT]: Adding viewer agent to scene"); m_scene.AddNewClient(this, true); } @@ -458,13 +460,13 @@ namespace OpenSim.Region.ClientStack if (!sessionInfo.Authorised) { //session/circuit not authorised - MainLog.Instance.Notice("CLIENT", "New user request denied to " + m_userEndPoint.ToString()); + m_log.Info("[CLIENT]: New user request denied to " + m_userEndPoint.ToString()); m_packetQueue.Close(); m_clientThread.Abort(); } else { - MainLog.Instance.Notice("CLIENT", "Got authenticated connection from " + m_userEndPoint.ToString()); + m_log.Info("[CLIENT]: Got authenticated connection from " + m_userEndPoint.ToString()); //session is authorised m_firstName = sessionInfo.LoginInfo.First; m_lastName = sessionInfo.LoginInfo.Last; @@ -731,7 +733,7 @@ namespace OpenSim.Region.ClientStack } catch (Exception e) { - MainLog.Instance.Warn("client", + m_log.Warn("[client]: " + "ClientView.API.cs: SendLayerData() - Failed with exception " + e.ToString()); } } @@ -758,7 +760,7 @@ namespace OpenSim.Region.ClientStack } catch (Exception e) { - MainLog.Instance.Warn("client", + m_log.Warn("[client]: " + "ClientView.API.cs: SendLayerData() - Failed with exception " + e.ToString()); } } @@ -2102,7 +2104,7 @@ namespace OpenSim.Region.ClientStack protected virtual bool Logout(IClientAPI client, Packet packet) { - MainLog.Instance.Verbose("CLIENT", "Got a logout request"); + m_log.Info("[CLIENT]: Got a logout request"); if (OnLogout != null) { @@ -2431,10 +2433,10 @@ namespace OpenSim.Region.ClientStack } catch (Exception e) { - MainLog.Instance.Warn("client", + m_log.Warn("[client]: " + "ClientView.m_packetQueue.cs:ProcessOutPacket() - WARNING: Socket exception occurred on connection " + m_userEndPoint.ToString() + " - killing thread"); - MainLog.Instance.Error(e.ToString()); + m_log.Error(e.ToString()); Close(true); } } @@ -2545,7 +2547,7 @@ namespace OpenSim.Region.ClientStack { if ((now - packet.TickCount > RESEND_TIMEOUT) && (!packet.Header.Resent)) { - MainLog.Instance.Verbose("NETWORK", "Resending " + packet.Type.ToString() + " packet, " + + m_log.Info("[NETWORK]: Resending " + packet.Type.ToString() + " packet, " + (now - packet.TickCount) + "ms have passed"); packet.Header.Resent = true; @@ -2564,11 +2566,11 @@ namespace OpenSim.Region.ClientStack if (m_pendingAcks.Count > 250) { // FIXME: Handle the odd case where we have too many pending ACKs queued up - MainLog.Instance.Verbose("NETWORK", "Too many ACKs queued up!"); + m_log.Info("[NETWORK]: Too many ACKs queued up!"); return; } - //MainLog.Instance.Verbose("NETWORK", "Sending PacketAck"); + //m_log.Info("[NETWORK]: Sending PacketAck"); int i = 0; PacketAckPacket acks = (PacketAckPacket)PacketPool.Instance.GetPacket(PacketType.PacketAck); @@ -2754,7 +2756,7 @@ namespace OpenSim.Region.ClientStack //rezPacket.RezData.RemoveItem; //rezPacket.RezData.RezSelected; //rezPacket.RezData.FromTaskID; - //MainLog.Instance.Verbose("REZData", rezPacket.ToString()); + //m_log.Info("[REZData]: " + rezPacket.ToString()); OnRezObject(this, rezPacket.InventoryData.ItemID, rezPacket.RezData.RayEnd, rezPacket.RezData.RayStart, rezPacket.RezData.RayTargetID, rezPacket.RezData.BypassRaycast, rezPacket.RezData.RayEndIsIntersection, @@ -2772,7 +2774,7 @@ namespace OpenSim.Region.ClientStack break; case PacketType.ModifyLand: ModifyLandPacket modify = (ModifyLandPacket)Pack; - //MainLog.Instance.Verbose("LAND", "LAND:" + modify.ToString()); + //m_log.Info("[LAND]: LAND:" + modify.ToString()); if (modify.ParcelData.Length > 0) { if (OnModifyTerrain != null) @@ -2941,7 +2943,7 @@ namespace OpenSim.Region.ClientStack { ObjectAddPacket addPacket = (ObjectAddPacket)Pack; PrimitiveBaseShape shape = GetShapeFromAddPacket(addPacket); - // MainLog.Instance.Verbose("REZData", addPacket.ToString()); + // m_log.Info("[REZData]: " + addPacket.ToString()); //BypassRaycast: 1 //RayStart: <69.79469, 158.2652, 98.40343> //RayEnd: <61.97724, 141.995, 92.58341> @@ -3068,7 +3070,7 @@ namespace OpenSim.Region.ClientStack } break; case PacketType.ObjectPermissions: - MainLog.Instance.Warn("CLIENT", "unhandled packet " + PacketType.ObjectPermissions.ToString()); + m_log.Warn("[CLIENT]: unhandled packet " + PacketType.ObjectPermissions.ToString()); ObjectPermissionsPacket newobjPerms = (ObjectPermissionsPacket)Pack; List permChanges = @@ -3344,7 +3346,7 @@ namespace OpenSim.Region.ClientStack } break; case PacketType.MoveTaskInventory: - MainLog.Instance.Warn("CLIENT", "unhandled MoveTaskInventory packet"); + m_log.Warn("[CLIENT]: unhandled MoveTaskInventory packet"); break; case PacketType.RezScript: //Console.WriteLine(Pack.ToString()); @@ -3594,7 +3596,7 @@ namespace OpenSim.Region.ClientStack break; case PacketType.GodKickUser: - MainLog.Instance.Warn("CLIENT", "unhandled GodKickUser packet"); + m_log.Warn("[CLIENT]: unhandled GodKickUser packet"); GodKickUserPacket gkupack = (GodKickUserPacket)Pack; @@ -3624,88 +3626,88 @@ namespace OpenSim.Region.ClientStack // Send the client the ping response back // Pass the same PingID in the matching packet // Handled In the packet processing - //MainLog.Instance.Debug("CLIENT", "possibly unhandled StartPingCheck packet"); + //m_log.Debug("[CLIENT]: possibly unhandled StartPingCheck packet"); break; case PacketType.CompletePingCheck: // TODO: Perhaps this should be processed on the Sim to determine whether or not to drop a dead client - //MainLog.Instance.Warn("CLIENT", "unhandled CompletePingCheck packet"); + //m_log.Warn("[CLIENT]: unhandled CompletePingCheck packet"); break; case PacketType.ObjectScale: // TODO: handle this packet - MainLog.Instance.Warn("CLIENT", "unhandled ObjectScale packet"); + m_log.Warn("[CLIENT]: unhandled ObjectScale packet"); break; case PacketType.ViewerStats: // TODO: handle this packet - MainLog.Instance.Warn("CLIENT", "unhandled ViewerStats packet"); + m_log.Warn("[CLIENT]: unhandled ViewerStats packet"); break; case PacketType.CreateGroupRequest: // TODO: handle this packet - MainLog.Instance.Warn("CLIENT", "unhandled CreateGroupRequest packet"); + m_log.Warn("[CLIENT]: unhandled CreateGroupRequest packet"); break; case PacketType.GenericMessage: // TODO: handle this packet - MainLog.Instance.Warn("CLIENT", "unhandled GenericMessage packet"); + m_log.Warn("[CLIENT]: unhandled GenericMessage packet"); break; case PacketType.MapItemRequest: // TODO: handle this packet - MainLog.Instance.Warn("CLIENT", "unhandled MapItemRequest packet"); + m_log.Warn("[CLIENT]: unhandled MapItemRequest packet"); break; case PacketType.AgentResume: // TODO: handle this packet - MainLog.Instance.Warn("CLIENT", "unhandled AgentResume packet"); + m_log.Warn("[CLIENT]: unhandled AgentResume packet"); break; case PacketType.AgentPause: // TODO: handle this packet - MainLog.Instance.Warn("CLIENT", "unhandled AgentPause packet"); + m_log.Warn("[CLIENT]: unhandled AgentPause packet"); break; case PacketType.TransferAbort: // TODO: handle this packet - MainLog.Instance.Warn("CLIENT", "unhandled TransferAbort packet"); + m_log.Warn("[CLIENT]: unhandled TransferAbort packet"); break; case PacketType.MuteListRequest: // TODO: handle this packet - MainLog.Instance.Warn("CLIENT", "unhandled MuteListRequest packet"); + m_log.Warn("[CLIENT]: unhandled MuteListRequest packet"); break; case PacketType.AgentDataUpdateRequest: // TODO: handle this packet - MainLog.Instance.Warn("CLIENT", "unhandled AgentDataUpdateRequest packet"); + m_log.Warn("[CLIENT]: unhandled AgentDataUpdateRequest packet"); break; case PacketType.ParcelDwellRequest: // TODO: handle this packet - MainLog.Instance.Warn("CLIENT", "unhandled ParcelDwellRequest packet"); + m_log.Warn("[CLIENT]: unhandled ParcelDwellRequest packet"); break; case PacketType.UseCircuitCode: // TODO: handle this packet - //MainLog.Instance.Warn("CLIENT", "unhandled UseCircuitCode packet"); + //m_log.Warn("[CLIENT]: unhandled UseCircuitCode packet"); break; case PacketType.EconomyDataRequest: // TODO: handle this packet - MainLog.Instance.Warn("CLIENT", "unhandled EconomyDataRequest packet"); + m_log.Warn("[CLIENT]: unhandled EconomyDataRequest packet"); break; case PacketType.AgentHeightWidth: // TODO: handle this packet - MainLog.Instance.Warn("CLIENT", "unhandled AgentHeightWidth packet"); + m_log.Warn("[CLIENT]: unhandled AgentHeightWidth packet"); break; case PacketType.ObjectSpinStop: // TODO: handle this packet - MainLog.Instance.Warn("CLIENT", "unhandled ObjectSpinStop packet"); + m_log.Warn("[CLIENT]: unhandled ObjectSpinStop packet"); break; case PacketType.SoundTrigger: // TODO: handle this packet - MainLog.Instance.Warn("CLIENT", "unhandled SoundTrigger packet"); + m_log.Warn("[CLIENT]: unhandled SoundTrigger packet"); break; case PacketType.UserInfoRequest: // TODO: handle this packet - MainLog.Instance.Warn("CLIENT", "unhandled UserInfoRequest packet"); + m_log.Warn("[CLIENT]: unhandled UserInfoRequest packet"); break; case PacketType.InventoryDescendents: // TODO: handle this packet - MainLog.Instance.Warn("CLIENT", "unhandled InventoryDescent packet"); + m_log.Warn("[CLIENT]: unhandled InventoryDescent packet"); break; default: - MainLog.Instance.Warn("CLIENT", "unhandled packet " + Pack.ToString()); + m_log.Warn("[CLIENT]: unhandled packet " + Pack.ToString()); break; #endregion diff --git a/OpenSim/Region/ClientStack/PacketQueue.cs b/OpenSim/Region/ClientStack/PacketQueue.cs index 685f91b..8b2a93a 100644 --- a/OpenSim/Region/ClientStack/PacketQueue.cs +++ b/OpenSim/Region/ClientStack/PacketQueue.cs @@ -37,6 +37,8 @@ namespace OpenSim.Region.ClientStack { public class PacketQueue { + private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); + private bool m_enabled = true; private BlockingQueue SendQueue; @@ -204,7 +206,7 @@ namespace OpenSim.Region.ClientStack SendQueue.Enqueue(AssetOutgoingPacketQueue.Dequeue()); } } - // MainLog.Instance.Verbose("THROTTLE", "Processed " + throttleLoops + " packets"); + // m_log.Info("[THROTTLE]: Processed " + throttleLoops + " packets"); } } @@ -253,7 +255,7 @@ namespace OpenSim.Region.ClientStack lock (this) { ResetCounters(); - // MainLog.Instance.Verbose("THROTTLE", "Entering Throttle"); + // m_log.Info("[THROTTLE]: Entering Throttle"); while (TotalThrottle.UnderLimit() && PacketsWaiting() && (throttleLoops <= MaxThrottleLoops)) { @@ -316,7 +318,7 @@ namespace OpenSim.Region.ClientStack AssetThrottle.Add(qpack.Packet.ToBytes().Length); } } - // MainLog.Instance.Verbose("THROTTLE", "Processed " + throttleLoops + " packets"); + // m_log.Info("[THROTTLE]: Processed " + throttleLoops + " packets"); } } @@ -426,7 +428,7 @@ namespace OpenSim.Region.ClientStack tall = tResend + tLand + tWind + tCloud + tTask + tTexture + tAsset; /* - MainLog.Instance.Verbose("CLIENT", "Client AgentThrottle - Got throttle:resendbytes=" + tResend + + m_log.Info("[CLIENT]: Client AgentThrottle - Got throttle:resendbytes=" + tResend + " landbytes=" + tLand + " windbytes=" + tWind + " cloudbytes=" + tCloud + diff --git a/OpenSim/Region/ClientStack/RegionApplicationBase.cs b/OpenSim/Region/ClientStack/RegionApplicationBase.cs index 72917d1..8a042b1 100644 --- a/OpenSim/Region/ClientStack/RegionApplicationBase.cs +++ b/OpenSim/Region/ClientStack/RegionApplicationBase.cs @@ -42,6 +42,8 @@ namespace OpenSim.Region.ClientStack { public abstract class RegionApplicationBase : BaseOpenSimServer { + private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); + protected AssetCache m_assetCache; protected Dictionary m_clientCircuits = new Dictionary(); protected NetworkServersInfo m_networkServersInfo; @@ -75,19 +77,20 @@ namespace OpenSim.Region.ClientStack m_httpServer = new BaseHttpServer(m_httpServerPort); - m_log.Status("REGION", "Starting HTTP server"); + m_log.Info("[REGION]: Starting HTTP server"); + m_httpServer.Start(); } protected abstract void Initialize(); - protected void StartLog() + protected void StartConsole() { - m_log = CreateLog(); - MainLog.Instance = m_log; + m_console = CreateConsole(); + MainConsole.Instance = m_console; } - protected abstract LogBase CreateLog(); + protected abstract ConsoleBase CreateConsole(); protected abstract PhysicsScene GetPhysicsScene(); protected abstract StorageManager CreateStorageManager(string connectionstring); @@ -107,7 +110,7 @@ namespace OpenSim.Region.ClientStack // listenIP = IPAddress.Parse("0.0.0.0"); uint port = (uint) regionInfo.InternalEndPoint.Port; - udpServer = new UDPServer(listenIP, ref port, regionInfo.m_allow_alternate_ports, m_assetCache, m_log, circuitManager); + udpServer = new UDPServer(listenIP, ref port, regionInfo.m_allow_alternate_ports, m_assetCache, circuitManager); regionInfo.InternalEndPoint.Port = (int)port; Scene scene = CreateScene(regionInfo, m_storageManager, circuitManager); @@ -136,12 +139,12 @@ namespace OpenSim.Region.ClientStack if (masterAvatar != null) { - m_log.Verbose("PARCEL", "Found master avatar [" + masterAvatar.UUID.ToString() + "]"); + m_log.Info("[PARCEL]: Found master avatar [" + masterAvatar.UUID.ToString() + "]"); scene.RegionInfo.MasterAvatarAssignedUUID = masterAvatar.UUID; } else { - m_log.Verbose("PARCEL", "No master avatar found, using null."); + m_log.Info("[PARCEL]: No master avatar found, using null."); scene.RegionInfo.MasterAvatarAssignedUUID = LLUUID.Zero; } 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