/// <summary> /// Write error to the File location /// </summary> /// <param name="message"></param> /// <param name="messageType"></param> /// <param name="type"></param> static void WriteError(string message, MessageType messageType, Type type) { CallMethod method = new CallMethod(type); string location = System.Environment.NewLine + METHOD + method.MethodNameFull + System.Environment.NewLine + LINE + method.LineNumber + System.Environment.NewLine + MESSAGE_TYPE + messageType; messageWriter.Write(message + SPACE + location, ERROR); }
/// <summary> /// Write trace to the File location /// </summary> /// <param name="message"></param> /// <param name="messageType"></param> /// <param name="type"></param> /// <param name="startTime"></param> public static void WriteLog(string message, MessageType messageType, Type type, DateTime startTime, string filePath) { DateTime endTime = DateTime.Now; TimeSpan ts = endTime.Subtract(startTime); CallMethod method = new CallMethod(type); string location = System.Environment.NewLine + METHOD + method.MethodNameFull + System.Environment.NewLine + LINE + method.LineNumber + System.Environment.NewLine + MESSAGE_TYPE + messageType; if (!Directory.Exists(filePath)) { Directory.CreateDirectory(filePath); } else if (!Directory.Exists(filePath + "\\Log")) { Directory.CreateDirectory(filePath + "\\Log"); } StreamWriter sw = new StreamWriter(filePath + "\\Log\\" + messageType + ".log", true); sw.WriteLine("-------------------------------------------------------------------------------------------------------------"); sw.WriteLine(message + System.Environment.NewLine + "Start Time :" + startTime.ToString() + System.Environment.NewLine + "End Time :" + endTime.ToString() + System.Environment.NewLine + "Time Spent:" + ts.ToString() + location); sw.WriteLine("-------------------------------------------------------------------------------------------------------------"); sw.Close(); }
/// <summary> /// Write message to the File location /// </summary> /// <param name="message"></param> /// <param name="messageType"></param> /// <param name="type"></param> static void WriteLog(string message, MessageType messageType, Type type) { CallMethod method = new CallMethod(type); messageWriter.Write(message, MESSAGE); }