public static void Informational(string text, bool silent = false) { LogToFile(Path.Combine(LogsDirectory, "informational.txt"), $"[{DateTime.Now}] {text}{Environment.NewLine}"); if (!silent) { PrettyConsole.WriteLine($"Informational: {text}"); } }
public static void Warning(string text, bool bypassEmail = false) { LogToFile(Path.Combine(LogsDirectory, "warning.txt"), $"[{DateTime.Now}] {text}{Environment.NewLine}"); PrettyConsole.WriteLine($"Warning: {text}", ConsoleColor.Yellow); string warningScreenshot = null; if (ScreenshotOnWarning) { warningScreenshot = Screenshot("warning"); } if (EmailOnWarning && !bypassEmail) { if (string.IsNullOrEmpty(warningScreenshot)) { EmailHelper.SendEmail(EmailAddressToAlert, text, $"{Environment.MachineName} Warning"); } else { EmailHelper.SendEmailWithAttachment(EmailAddressToAlert, text, warningScreenshot, $"{Environment.MachineName} Warning"); } } }
public static void Error(string text, bool bypassEmail = false) { LogToFile(Path.Combine(LogsDirectory, "error.txt"), $"[{DateTime.Now}] {text}{Environment.NewLine}"); PrettyConsole.WriteLine($"Error: {text}", ConsoleColor.Red); string errorScreenshot = null; if (ScreenshotOnError) { errorScreenshot = Screenshot("warning"); } if (EmailOnError && !bypassEmail) { if (string.IsNullOrEmpty(errorScreenshot)) { EmailHelper.SendEmail(EmailAddressToAlert, text, $"{Environment.MachineName} Error"); } else { EmailHelper.SendEmailWithAttachment(EmailAddressToAlert, text, errorScreenshot, $"{Environment.MachineName} Error"); } } }