/// <summary> Public method for posting message in logFile </summary> /// <param name="text">Message for saving</param> /// <param name="messageType">Message type (error, warning or information)</param> /// <param name="showMessage">Show messagebox to user</param> public static void EchoToLog(string text, EchoMessageType messageType, bool showMessage = false) { var date = DateTime.Now; WriteMessageToLog(date.ToLongDateString() + " " + date.ToLongTimeString() + " " + date.Millisecond + " " + // get current date and time messageType.GetTitle() + " " + // get message type caption text); // Such precision in time will facilitate program debugging, in case of errors if (showMessage) { MessageBox.Show(text, messageType.GetTitle(), MessageBoxButtons.OK); } }
/// <summary> Get title for enum </summary> /// <param name="messageType">enum element</param> /// <returns>Title of enum element</returns> public static string GetTitle(this EchoMessageType messageType) { switch (messageType) { case EchoMessageType.Information: return("Information"); case EchoMessageType.Warning: return("Warning"); case EchoMessageType.Error: return("Error"); default: return(string.Empty); } }
/// <summary> Public method for posting message in logFile </summary> /// <param name="text">Message for saving</param> /// <param name="messageType">Message type (error, warning or information)</param> /// <param name="showMessage">Show messagebox to user</param> public static void EchoToLog(string text, EchoMessageType messageType, bool showMessage = false) { var date = DateTime.Now; WriteMessageToLog(date.ToLongDateString() + " " + date.ToLongTimeString() + " " + date.Millisecond + " " + // get current date and time messageType.GetTitle() + " " + // get message type caption text); // Such precision in time will facilitate program debugging, in case of errors if (showMessage) MessageBox.Show(text, messageType.GetTitle(), MessageBoxButtons.OK); }