From 6e2c7da0182c0ee5bf95cb50e95878caa968a77b Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Fri, 9 May 2008 15:51:02 +0000 Subject: [PATCH] * Minor: Insert utility function to format raw xml strings into indented xml for debugging purposes --- .../Cache/UserProfileCacheService.cs | 4 ++- .../Communications/Capabilities/Caps.cs | 7 ++-- OpenSim/Framework/Util.cs | 36 ++++++++++++++++++- 3 files changed, 42 insertions(+), 5 deletions(-) diff --git a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs index 314343757d..b16768208f 100644 --- a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs +++ b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs @@ -341,7 +341,9 @@ namespace OpenSim.Framework.Communications.Cache public List HandleFetchInventoryDescendentsCAPS(LLUUID agentID, LLUUID folderID, LLUUID ownerID, bool fetchFolders, bool fetchItems, int sortOrder) { - //m_log.DebugFormat("[INVENTORY CACHE]: Fetching folders/items from {0} for agent {1}", folderID, agentID); +// m_log.DebugFormat( +// "[INVENTORY CACHE]: Fetching folders ({0}), items ({1}) from {2} for agent {3}", +// fetchFolders, fetchItems, folderID, agentID); // XXX We're not handling sortOrder yet! diff --git a/OpenSim/Framework/Communications/Capabilities/Caps.cs b/OpenSim/Framework/Communications/Capabilities/Caps.cs index 8061e2831f..ad3d79d9f4 100644 --- a/OpenSim/Framework/Communications/Capabilities/Caps.cs +++ b/OpenSim/Framework/Communications/Capabilities/Caps.cs @@ -269,8 +269,9 @@ namespace OpenSim.Framework.Communications.Capabilities { response = "folders" + response + ""; } - - //m_log.DebugFormat("[AGENT INVENTORY]: Replying to CAPS fetch inventory request {0}", response); + + //m_log.DebugFormat("[AGENT INVENTORY]: Replying to CAPS fetch inventory request with following xml"); + //m_log.Debug(Util.GetFormattedXml(response)); return response; } @@ -960,4 +961,4 @@ namespace OpenSim.Framework.Communications.Capabilities } } } -} \ No newline at end of file +} diff --git a/OpenSim/Framework/Util.cs b/OpenSim/Framework/Util.cs index 094362649d..5577140747 100644 --- a/OpenSim/Framework/Util.cs +++ b/OpenSim/Framework/Util.cs @@ -36,6 +36,7 @@ using System.Runtime.Serialization.Formatters.Binary; using System.Security.Cryptography; using System.Text; using System.Text.RegularExpressions; +using System.Xml; using libsecondlife; using log4net; using Nini.Config; @@ -43,6 +44,9 @@ using Nwc.XmlRpc; namespace OpenSim.Framework { + /// + /// Miscellaneous utility functions + /// public class Util { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); @@ -161,6 +165,36 @@ namespace OpenSim.Framework // (but those probably wont work anyway) return file; } + + /// + /// Debug utility function to convert unbroken strings of XML into something human readable for occasional debugging purposes. + /// + /// Please don't delete me even if I appear currently unused! + /// + /// + /// + public static string GetFormattedXml(string rawXml) + { + XmlDocument xd = new XmlDocument(); + xd.LoadXml(rawXml); + + StringBuilder sb = new StringBuilder(); + StringWriter sw = new StringWriter(sb); + + XmlTextWriter xtw = new XmlTextWriter(sw); + xtw.Formatting = Formatting.Indented; + + try + { + xd.WriteTo(xtw); + } + finally + { + xtw.Close(); + } + + return sb.ToString(); + } public static bool IsEnvironmentSupported(ref string reason) { @@ -634,4 +668,4 @@ namespace OpenSim.Framework return client.Send(url, 6000); } } -} \ No newline at end of file +}