/// <summary> /// Writes the report to the designated receiver. /// </summary> private static void WriteReport(MessageType DebugMessageType, string Title, string Body) { //Test for the current Filter. bool shouldReport = false; //We always report internal messages... if (DebugMessageType == MessageType.Internal) { shouldReport = true; } else { switch (DebugMessageType) { case MessageType.Information: if ((DebugLevels.Information & DebugReporter._outPutFilter) > 0) { shouldReport = true; } break; case MessageType.Warning: if ((DebugLevels.Warning & DebugReporter._outPutFilter) > 0) { shouldReport = true; } break; case MessageType.Error: if ((DebugLevels.Error & DebugReporter._outPutFilter) > 0) { shouldReport = true; } break; default: break; } } if (!shouldReport) { return; } if (DebugReporter._dManagerStatus != ReporterStatus.OK) { throw new ApplicationException(DebugReporter.Name + " - The Debug Reporter is no longer alive. Cannot Write Report."); } //Get some additional data on the current stack frame. StackFrame frame = new StackFrame(2, true); string method = frame.GetMethod().Name; string file = frame.GetFileName(); string line = frame.GetFileLineNumber().ToString(); string typename = frame.GetMethod().DeclaringType.FullName; string TimeStamp = DateTimeStringBuilder.GetDateTimeString(); try { switch (DebugReporter._debugMode) { case DebugMode.None: break; case DebugMode.File: DebugReporter.ReportToFile(DebugMessageType, TimeStamp, file, method, line, typename, Title, Body); break; case DebugMode.Email: DebugReporter.ReportToEmail(DebugMessageType, TimeStamp, file, method, line, typename, Title, Body); break; case DebugMode.Console: DebugReporter.ReportToConsole(DebugMessageType, TimeStamp, file, method, line, typename, Title, Body); break; case DebugMode.Output: DebugReporter.ReportToOutput(DebugMessageType, TimeStamp, file, method, line, typename, Title, Body); break; case DebugMode.Wreq_v1: DebugReporter.ReportToWreq_v1(DebugMessageType, TimeStamp, file, method, line, typename, Title, Body); break; default: break; } } catch (Exception ex) { DebugReporter.KillDebugReporter("Failed to Write Report.\nException:\n" + ex.Message); throw new ApplicationException(TimeStamp + DebugReporter.Name + "Unhandled Excpetion:\n" + ex.Message); } }
private static void SetDebugMode(DebugMode mode) { //Perform Setup for the new mode... switch (mode) { case DebugMode.File: try { FileInfo fi = new FileInfo(DebugReporter._outputFilePath); if (!Directory.Exists(fi.Directory.FullName)) { Directory.CreateDirectory(fi.Directory.FullName); } if (File.Exists(DebugReporter._outputFilePath)) { break; } else { File.CreateText(DebugReporter._outputFilePath).Close(); } DebugReporter._debugMode = mode; } catch (Exception ex) { DebugReporter.KillDebugReporter("Failed to set DebugMode File.\nException:\n" + ex.Message); return; } break; case DebugMode.Email: throw new NotImplementedException("This feature is not available in this project..."); case DebugMode.Console: try { DebugReporter.OpenDebugConsole(); DebugReporter._debugMode = mode; } catch (Exception ex) { DebugReporter.KillDebugReporter("Failed to set DebugMode Console.\nException:\n" + ex.Message); return; } break; case DebugMode.Wreq_v1: throw new NotImplementedException("This feature is not available in this project..."); case DebugMode.None: DebugReporter._debugMode = mode; break; default: break; } DebugReporter.Report(MessageType.Internal, "Debug mode changed.", "DebugReporter Debug Mode changed to:\n" + DebugReporter._debugMode.ToString()); }