private static string FormatMessage(TDebugLevel tLevel, System.Object logObject) { string strDebugLevel = "[UNKNOWN]"; switch (tLevel) { case TDebugLevel.enLog: strDebugLevel = "[I]"; break; case TDebugLevel.enWarning: strDebugLevel = "[W]"; break; case TDebugLevel.enError: strDebugLevel = "[E]"; break; case TDebugLevel.enException: strDebugLevel = "[X]"; break; } // Index Time Level Message string strFormatedMsg = string.Format("{0}\t{1}\t{2}\t{3}", m_nIndex++, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss,fff"), strDebugLevel, logObject); if (m_bWithStackInfo == true) { strFormatedMsg += "\n" + GetStacksInfo(); } return(strFormatedMsg); }
/// <summary> /// 取消重定向输出 /// </summary> /// <param name="handle"></param> /// <param name="tDebugType"></param> /// <returns></returns> public static bool UnRegisterHandle(HandleObjectAction handle, TDebugLevel tDebugType) { if (handle == null) { return(false); } switch (tDebugType) { case TDebugLevel.enLog: { m_handleLog -= handle; } break; case TDebugLevel.enWarning: { m_handleWarning -= handle; } break; case TDebugLevel.enError: { m_handleError -= handle; } break; case TDebugLevel.enException: { m_handleException -= handle; } break; default: { return(false); } } return(true); }