private static void Log(DbgData dd, string format, params object[] args) { IndentKey ik = dd.GetIndentKey(); IndentContext iu = IndentManager.GetInstance().Get(ik); if (format == "<") { if (!iu.Unindent()) { Debug.WriteLine(String.Format("[{0}][{1}]<{2}>Warning : log indent error", project_key, dd.thread_id, iu.GetContextId())); } } string indentStr = iu.GetIndent(); string dbgStr; if (dd.file_name == null) { dbgStr = String.Format("[{0}][{1}]<{2}>{3}{4}[{5}]", project_key, dd.thread_id, iu.GetContextId(), indentStr, dd.method_full_name, dd.thread_name); } else { dbgStr = String.Format("[{0}][{1}]<{2}>{3}{4}({5}){6}[{7}]", project_key, dd.thread_id, iu.GetContextId(), indentStr, dd.file_name, dd.line_number, dd.method_name, dd.thread_name); } string logStr = String.Format(format, args); string finalStr = String.Format("{0} : {1}", dbgStr, logStr); //Console.WriteLine(finalStr); Debug.WriteLine(finalStr); //Debugger.Log(0, null, finalStr); //OutputDebugString(finalStr); if (format == ">") { iu.Indent(); } }
public static void RestoreContext(IndentContext iu) { #if DEBUG StackFrame sf = new StackFrame(1, true); DbgData dd = new DbgData(sf); IndentKey ik = dd.GetIndentKey(); IndentManager.GetInstance().Put(ik, iu); Log(dd, "RestoreContext()"); #endif }
public static IndentManager GetInstance() { if (instance == null) { lock (locker) { if (instance == null) { instance = new IndentManager(); } } } return(instance); }
public static IndentContext SaveContextAndShuffle() { #if DEBUG StackFrame sf = new StackFrame(1, true); DbgData dd = new DbgData(sf); Log(dd, "SaveContextAndShuffle()"); IndentKey ik = dd.GetIndentKey(); IndentContext iu = IndentManager.GetInstance().Get(ik); IndentContext copy = new IndentContext(iu); iu.ShuffleContext(); return(copy); #else return(null); #endif }
public void ShuffleContext() { context_id = IndentManager.GetInstance().GetNextContextId(); }