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

0.7.5-pf-bulletsim
Robert Adams 2012-12-16 17:53:44 -08:00
parent f3b1efd889
commit 21dc5f4a1a
1 changed files with 7 additions and 1 deletions

View File

@ -1854,6 +1854,12 @@ namespace OpenSim.Framework
/// Prints the call stack at any given point. Useful for debugging. /// Prints the call stack at any given point. Useful for debugging.
/// </summary> /// </summary>
public static void PrintCallStack() 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 StackTrace stackTrace = new StackTrace(true); // get call stack
StackFrame[] stackFrames = stackTrace.GetFrames(); // get method calls (frames) StackFrame[] stackFrames = stackTrace.GetFrames(); // get method calls (frames)
@ -1862,7 +1868,7 @@ namespace OpenSim.Framework
foreach (StackFrame stackFrame in stackFrames) foreach (StackFrame stackFrame in stackFrames)
{ {
MethodBase mb = stackFrame.GetMethod(); 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
} }
} }