public void TraceEntry(string methodName, LogArgs args) { if (!IsTraceEnabled) { return; } const string ENTRY_FORMAT = "-> {0}({1})"; try { if (_indentLevel == 0) { TraceFormatted(ENTRY_FORMAT, methodName, GetParamtersString(args)); } else { TraceFormatted(GetIndentedMessage(ENTRY_FORMAT), methodName, GetParamtersString(args)); } } catch (Exception ex) { System.Diagnostics.Trace.Fail("Error in logger", ex.Message); } }
public void Entry(string methodName, LogArgs args) { if (!_logTarget.IsDebugEnabled) { return; } const string ENTRY_FORMAT = "-> {0}({1})"; try { if (_indentLevel == 0) { _logTarget.DebugFormat(ENTRY_FORMAT, methodName, GetParamtersString(args)); } else { _logTarget.DebugFormat(GetIndentedMessage(ENTRY_FORMAT), methodName, GetParamtersString(args)); } } catch (Exception ex) { System.Diagnostics.Debug.Fail("Error in logger", ex.Message); } }
private string GetParamtersString(LogArgs arg) { if ((arg == null) || (arg.ParamNames.Count == 0)) { return(string.Empty); } string argstring = string.Empty; for (int i = 0; i < arg.ParamNames.Count; i++) { if (arg.ParamNames[i] != null) { object currentObject = arg.ParamValus[i]; string paramValue; if (currentObject == null) { paramValue = NullStr; } else { var methodInfo = currentObject.GetType().GetMethod("ToString", new Type[] { }); if (methodInfo.DeclaringType == currentObject.GetType()) { paramValue = currentObject.ToString(); } else { paramValue = "{...}"; } } if (string.IsNullOrEmpty(argstring)) { argstring = string.Format("{0} = {1}", arg.ParamNames[i], paramValue); } else { argstring = string.Format("{0}, {1} = {2}", argstring, arg.ParamNames[i], paramValue); } } } return(argstring); }