public TraceLogInfo(string pMessage, eTRACELEVEL pTraceLevel)
 {
     this.ThreadID   = string.Empty;
     this.TraceID    = LogTraceToFile.defTraceID;
     this.TraceLevel = pTraceLevel;
     this.Message    = pMessage;
 }
 public TraceLogInfo(string pMessage, eTRACELEVEL pTraceLevel, string pTraceID)
 {
     this.ThreadID   = string.Empty;
     this.TraceID    = pTraceID;
     this.TraceLevel = pTraceLevel;
     this.Message    = pMessage;
 }
 // Methods
 public TraceLogInfo(string pMessage)
 {
     this.ThreadID   = string.Empty;
     this.TraceID    = LogTraceToFile.defTraceID;
     this.TraceLevel = eTRACELEVEL.INFORMATION;
     this.Message    = pMessage;
 }
        public static void WriteLog(string className, string functionName, string Msg, eTRACELEVEL traceLevel, string TraceID)
        {
            StringBuilder builder = new StringBuilder();

            if (className.Trim().Length > 0)
            {
                builder.AppendFormat("[{0}]::", className);
            }
            if (functionName.Trim().Length > 0)
            {
                builder.AppendFormat("[{0}]::", functionName);
            }
            builder.Append(Msg);
            TraceID = TraceID.Trim();
            LogTraceToFile.WriteLog(new TraceLogInfo(builder.ToString(), traceLevel, (TraceID.Length == 0) ? string.Empty : TraceID));
        }
 public static void WriteLog(string className, string Msg, eTRACELEVEL traceLevel, string TraceID)
 {
     WriteLog(className, string.Empty, Msg, traceLevel, TraceID);
 }
 public static void WriteLog(string Msg, eTRACELEVEL traceLevel)
 {
     WriteLog(string.Empty, string.Empty, Msg, traceLevel, string.Empty);
 }
Ejemplo n.º 7
0
        /// <summary>
        /// Writes Trace Log into the Log File.
        /// </summary>
        /// <param name="className">The Class Name which generate the Trace.</param>
        /// <param name="functionName">The Function Name which generate the Trace.</param>
        /// <param name="Msg">The Trace Message to be logged.</param>
        /// <param name="traceLevel">The Trace Log information category.</param>
        /// <param name="TraceID">The TraceID or File ID in which trace Info is to be logged.</param>
        public static void WriteLog(string className, string functionName, string Msg, eTRACELEVEL traceLevel, string TraceID)
        {
            StackTrace stackTrace = new StackTrace();
            StackFrame stackFrame = stackTrace.GetFrame(2);
            MethodBase methodBase = stackFrame.GetMethod();

            StringBuilder tmpMsg = new StringBuilder();

            if (className.Trim().Length > 0)
            {
                tmpMsg.AppendFormat("[{0}]::", className);
            }
            else
            {
                tmpMsg.AppendFormat("[{0}]::", methodBase.DeclaringType.Name);
            }

            if (functionName.Trim().Length > 0)
            {
                tmpMsg.AppendFormat("[{0}]::", functionName);
            }
            else
            {
                tmpMsg.AppendFormat("[{0}]::", methodBase.Name);
            }
            tmpMsg.Append(Msg);

            TraceID = TraceID.Trim();
            LogTraceToFile.WriteLog(new TraceLogInfo(tmpMsg.ToString(), traceLevel, TraceID.Length == 0 ? string.Empty : TraceID));
            //Trace Write Message Format.
            //[ClassName]  [FunctionName] Message

            //if (traceLevel == eTRACELEVEL.ERROR)o
            //    Utility.MsgBox(Msg);
        }