From 21dc5f4a1ada6fa7538627a81907054c619c0ebb Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Sun, 16 Dec 2012 17:53:44 -0800 Subject: [PATCH] Add stack dump function that takes an alternate printer outter. I've found that log4net can be slowish so, if one is generating A LOT of debug output, alternate printers are better --- OpenSim/Framework/Util.cs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/OpenSim/Framework/Util.cs b/OpenSim/Framework/Util.cs index a0c54a027e..0c657c51eb 100644 --- a/OpenSim/Framework/Util.cs +++ b/OpenSim/Framework/Util.cs @@ -1854,6 +1854,12 @@ namespace OpenSim.Framework /// Prints the call stack at any given point. Useful for debugging. /// public static void PrintCallStack() + { + PrintCallStack(m_log.DebugFormat); + } + + public delegate void DebugPrinter(string msg, params Object[] parm); + public static void PrintCallStack(DebugPrinter printer) { StackTrace stackTrace = new StackTrace(true); // get call stack StackFrame[] stackFrames = stackTrace.GetFrames(); // get method calls (frames) @@ -1862,7 +1868,7 @@ namespace OpenSim.Framework foreach (StackFrame stackFrame in stackFrames) { MethodBase mb = stackFrame.GetMethod(); - m_log.DebugFormat("{0}.{1}:{2}", mb.DeclaringType, mb.Name, stackFrame.GetFileLineNumber()); // write method name + printer("{0}.{1}:{2}", mb.DeclaringType, mb.Name, stackFrame.GetFileLineNumber()); // write method name } }