public void Put(IndentKey key, IndentContext iu) { lock (locker) { indentDictionary[key.GetKey()] = iu; } }
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 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 IndentContext Get(IndentKey key) { string keyStr = key.GetKey(); lock (locker) { if (indentDictionary.ContainsKey(keyStr)) { return(indentDictionary[keyStr]); } else { IndentContext iu = new IndentContext(); indentDictionary.Add(keyStr, iu); return(iu); } } }