Ejemplo n.º 1
0
        /// <summary>
        /// Builds exceptions as string from message node. If this message node does not contain the exception  will be return empty string.
        /// </summary>
        /// <param name="msg">message as node</param>
        /// <param name="eLevel">log level exception</param>
        /// <returns>returns exceptions as string. If this message node does not contain the exception  will be return empty string.</returns>
        static public string GetLogException(this DDNode msg, DrLogSrv.LogExceptionLevel eLevel)
        {
            var result = new StringBuilder();

            if (eLevel == LogExceptionLevel.NONE)
            {
                return(String.Empty);                                  // supress log Exception
            }
            foreach (var n in msg)
            {
                if (n.Value.Type.Name == DDNode.TpException)
                {
                    result.Append("'" + BuildExceptionAsString(eLevel, n.Value) + "'");
                }
            }

            return(result.ToString());
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Builds exception as string from single exception node
        /// </summary>
        /// <param name="msg">exception message as node</param>
        /// <param name="eLevel">log level exception</param>
        /// <returns>returns exception exception as string from single exception node</returns>
        public static string BuildExceptionAsString(DrLogSrv.LogExceptionLevel eLevel, DDNode eNode)
        {
            var result = new StringBuilder();

            if ((eLevel & LogExceptionLevel.MESSAGE) == LogExceptionLevel.MESSAGE)
            {
                result.Append("'" + eNode.Attributes.GetValue(DDNode.AttMessage, string.Empty).GetValueAsString() + "'.");
            }
            if (((eLevel & LogExceptionLevel.SOURCE) == LogExceptionLevel.SOURCE) && (eNode.Attributes.Contains(DDNode.AttSource)))
            {
                result.Append(" Source: '" + eNode.Attributes.GetValue(DDNode.AttSource, string.Empty).GetValueAsString() + "'.");
            }
            if (((eLevel & LogExceptionLevel.TYPE) == LogExceptionLevel.TYPE) && (eNode.Attributes.Contains(DDNode.AttType)))
            {
                result.Append(" Type: '" + eNode.Attributes.GetValue(DDNode.AttType, string.Empty).GetValueAsString() + "'.");
            }
            if (((eLevel & LogExceptionLevel.STACK_TRACE) == LogExceptionLevel.STACK_TRACE) && (eNode.Attributes.Contains(DDNode.AttStackTrace)))
            {
                result.Append(" StackTrace: '" + eNode.Attributes.GetValue(DDNode.AttStackTrace, string.Empty).GetValueAsString() + "'.");
            }
            if (((eLevel & LogExceptionLevel.HELP_LINK) == LogExceptionLevel.HELP_LINK) && (eNode.Attributes.Contains(DDNode.AttHelpLink)))
            {
                result.Append(" HelpLink: '" + eNode.Attributes.GetValue(DDNode.AttHelpLink, string.Empty).GetValueAsString() + "'.");
            }

            if (((eLevel & LogExceptionLevel.DATA) == LogExceptionLevel.DATA) && (eNode.Contains(DDNode.NdData)))
            {
                result.Append(BuildExceptionDataAsString(eNode.GetNode(DDNode.NdData)));
            }

            if (((eLevel & LogExceptionLevel.INNERT_EXCEPTION) == LogExceptionLevel.INNERT_EXCEPTION) && (eNode.Contains(DDNode.NdInnerException)))
            {
                result.Append(" --> {");
                result.Append(BuildExceptionAsString(eLevel, eNode.GetNode(DDNode.NdInnerException)));
                result.Append("}.");
            }

            return(result.ToString());
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Update settings to current config
 /// </summary>
 virtual public void RebuildConfiguration()
 {
     this.Level          = (DrLogSrv.LogLevel)Enum.Parse(typeof(DrLogSrv.LogLevel), Config.Attributes.GetValue(SchemaProvider.AttLevel, DefaultLevel), true);
     this.ExceptionLevel = (DrLogSrv.LogExceptionLevel)Enum.Parse(typeof(DrLogSrv.LogExceptionLevel), Config.Attributes.GetValue(SchemaProvider.AttExceptionLevel, DrLogSrv.LogExceptionLevel.ALL), true);
 }