From 0174e326e3680ebc76dbd525191ad9b07634ec6d Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Thu, 24 Nov 2011 20:27:11 +0000
Subject: Add a "debug eq" console command for debugging.
This will log outgoing event queue message names if turned on.
---
.../Linden/Caps/EventQueue/EventQueueGetModule.cs | 85 ++++++++++++++++++++--
1 file changed, 79 insertions(+), 6 deletions(-)
(limited to 'OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs')
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs
index 7d73b3e..f5feb71 100644
--- a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs
+++ b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs
@@ -39,6 +39,7 @@ using OpenMetaverse.Messages.Linden;
using OpenMetaverse.Packets;
using OpenMetaverse.StructuredData;
using OpenSim.Framework;
+using OpenSim.Framework.Console;
using OpenSim.Framework.Servers;
using OpenSim.Framework.Servers.HttpServer;
using OpenSim.Region.Framework.Interfaces;
@@ -58,9 +59,15 @@ namespace OpenSim.Region.ClientStack.Linden
public class EventQueueGetModule : IEventQueue, IRegionModule
{
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
- protected Scene m_scene = null;
+
+ ///
+ /// Debug level.
+ ///
+ public int DebugLevel { get; set; }
+
+ protected Scene m_scene;
private IConfigSource m_gConfig;
- bool enabledYN = false;
+ bool enabledYN;
private Dictionary m_ids = new Dictionary();
@@ -97,6 +104,15 @@ namespace OpenSim.Region.ClientStack.Linden
scene.EventManager.OnClientClosed += ClientClosed;
scene.EventManager.OnMakeChildAgent += MakeChildAgent;
scene.EventManager.OnRegisterCaps += OnRegisterCaps;
+
+ MainConsole.Instance.Commands.AddCommand(
+ "event queue",
+ false,
+ "debug eq",
+ "debug eq [0|1]",
+ "debug eq 1 will turn on event queue debugging. This will log all outgoing event queue messages to clients.\n"
+ + "debug eq 1 will turn off event queue debugging.",
+ HandleDebugEq);
}
else
{
@@ -128,6 +144,22 @@ namespace OpenSim.Region.ClientStack.Linden
}
#endregion
+ protected void HandleDebugEq(string module, string[] args)
+ {
+ int debugLevel;
+
+ if (!(args.Length == 3 && int.TryParse(args[2], out debugLevel)))
+ {
+ MainConsole.Instance.OutputFormat("Usage: debug eq [0|1]");
+ }
+ else
+ {
+ DebugLevel = debugLevel;
+ MainConsole.Instance.OutputFormat(
+ "Set event queue debug level to {0} in {1}", DebugLevel, m_scene.RegionInfo.RegionName);
+ }
+ }
+
///
/// Always returns a valid queue
///
@@ -323,7 +355,9 @@ namespace OpenSim.Region.ClientStack.Linden
// This will persist this beyond the expiry of the caps handlers
MainServer.Instance.AddPollServiceHTTPHandler(
- capsBase + EventQueueGetUUID.ToString() + "/", EventQueuePoll, new PollServiceEventArgs(null, HasEvents, GetEvents, NoEvents, agentID));
+ capsBase + EventQueueGetUUID.ToString() + "/",
+ EventQueuePoll,
+ new PollServiceEventArgs(null, HasEvents, GetEvents, NoEvents, agentID));
Random rnd = new Random(Environment.TickCount);
lock (m_ids)
@@ -370,12 +404,31 @@ namespace OpenSim.Region.ClientStack.Linden
}
else
{
+ if (DebugLevel > 0 && element is OSDMap)
+ {
+ OSDMap ev = (OSDMap)element;
+ m_log.DebugFormat(
+ "[EVENT QUEUE GET MODULE]: Eq OUT {0} to {1}",
+ ev["message"], m_scene.GetScenePresence(pAgentId).Name);
+ }
+
array.Add(element);
+
lock (queue)
{
while (queue.Count > 0)
{
- array.Add(queue.Dequeue());
+ element = queue.Dequeue();
+
+ if (DebugLevel > 0 && element is OSDMap)
+ {
+ OSDMap ev = (OSDMap)element;
+ m_log.DebugFormat(
+ "[EVENT QUEUE GET MODULE]: Eq OUT {0} to {1}",
+ ev["message"], m_scene.GetScenePresence(pAgentId).Name);
+ }
+
+ array.Add(element);
thisID++;
}
}
@@ -471,11 +524,29 @@ namespace OpenSim.Region.ClientStack.Linden
{
array.Add(element);
+ if (element is OSDMap)
+ {
+ OSDMap ev = (OSDMap)element;
+ m_log.DebugFormat(
+ "[EVENT QUEUE GET MODULE]: Eq OUT {0} to {1}",
+ ev["message"], m_scene.GetScenePresence(agentID).Name);
+ }
+
lock (queue)
{
while (queue.Count > 0)
{
- array.Add(queue.Dequeue());
+ element = queue.Dequeue();
+
+ if (element is OSDMap)
+ {
+ OSDMap ev = (OSDMap)element;
+ m_log.DebugFormat(
+ "[EVENT QUEUE GET MODULE]: Eq OUT {0} to {1}",
+ ev["message"], m_scene.GetScenePresence(agentID).Name);
+ }
+
+ array.Add(element);
thisID++;
}
}
@@ -494,7 +565,8 @@ namespace OpenSim.Region.ClientStack.Linden
responsedata["content_type"] = "application/xml";
responsedata["keepalive"] = false;
responsedata["str_response_string"] = OSDParser.SerializeLLSDXmlString(events);
- //m_log.DebugFormat("[EVENTQUEUE]: sending response for {0} in region {1}: {2}", agentID, m_scene.RegionInfo.RegionName, responsedata["str_response_string"]);
+
+ m_log.DebugFormat("[EVENTQUEUE]: sending response for {0} in region {1}: {2}", agentID, m_scene.RegionInfo.RegionName, responsedata["str_response_string"]);
return responsedata;
}
@@ -717,6 +789,7 @@ namespace OpenSim.Region.ClientStack.Linden
OSD item = EventQueueHelper.GroupMembership(groupUpdate);
Enqueue(item, avatarID);
}
+
public void QueryReply(PlacesReplyPacket groupUpdate, UUID avatarID)
{
OSD item = EventQueueHelper.PlacesQuery(groupUpdate);
--
cgit v1.1