public MainForm() { try // can't be handled by exception manager because it doesn't exist yet { InitializeComponent(); m_GlobalModel = new GlobalStateModel(); m_Document = new DocumentModel(); m_Document.GlobalModel = m_GlobalModel; m_GlobalModel.InitEnterpriseBlocks(m_Document); } catch (Exception e) { throw e; } m_GlobalModel.ExManager.Process(() => { Process.GetCurrentProcess().PriorityClass = ProcessPriorityClass.High; // Prevents "Normal" processes OutputWindow f1 = new OutputWindow(); f1.Show(dockPanel, DockState.DockBottom); CodeExplorer f3 = new CodeExplorer(); f3.Show(dockPanel, DockState.DockRight); RenderWindow f2 = new RenderWindow(m_Document); f2.CloseButtonVisible = false; f2.Show(dockPanel, DockState.Document); f4 = new DebugView(m_Document); f4.Show(dockPanel, DockState.DockRight); f4.Hide(); ActionView f5 = new ActionView(); f5.Show(dockPanel, DockState.DockRight); f5.Hide(); m_GlobalModel.AddOutputObserver(f1); m_GlobalModel.AddDebugMessageObserver(f4); m_Document.AddNCTextObserver(f3); m_Document.ReadConfigFile(); m_Document.AddAnimationStateObserver(this); m_GlobalModel.OutputWriter.Write("Application started" + Environment.NewLine, "Output", 0); }, "LoggingAndReplacingException"); }
internal static LoggingConfiguration BuildLoggingConfig(GlobalStateModel model) { // Formatters //TextFormatter formatter = new TextFormatter("Timestamp: {timestamp}{newline}Message: {message}{newline}Category: {category}{newline}Priority: {priority}{newline}EventId: {eventid}{newline}Severity: {severity}{newline}Title:{title}{newline}Machine: {localMachine}{newline}App Domain: {localAppDomain}{newline}ProcessId: {localProcessId}{newline}Process Name: {localProcessName}{newline}Thread Name: {threadName}{newline}Win32 ThreadId:{win32ThreadId}{newline}Extended Properties: {dictionary({key} - {value}{newline})}"); TextFormatter errorFormatter = new TextFormatter("{timestamp} {message}"); TextFormatter consoleFormatter = new TextFormatter("{timestamp} {severity} : {message}"); // Listeners var errorFlatFileTraceListener = new FlatFileTraceListener(Directory.GetCurrentDirectory() + "\\" + "Error.log", "----------------------------------------", "----------------------------------------", errorFormatter); var outputFlatFileTraceListener = new FlatFileTraceListener(Directory.GetCurrentDirectory() + "\\" + "Output.log", "----------------------------------------", "----------------------------------------", errorFormatter); var outputViewTraceListener = new OutputViewTraceListener(model, consoleFormatter); //var consoleTraceListener = new CustomTraceListener(); // Build Configuration var config = new LoggingConfiguration(); config.AddLogSource("Error", SourceLevels.All, true).AddTraceListener(errorFlatFileTraceListener); config.AddLogSource("Output", SourceLevels.All, true).AddTraceListener(outputViewTraceListener); config.LogSources["Output"].AddTraceListener(outputFlatFileTraceListener); config.AddLogSource("Debug", SourceLevels.All, true).AddTraceListener(outputViewTraceListener); config.AddLogSource("OutputToFile", SourceLevels.All, true).AddTraceListener(outputFlatFileTraceListener); return config; }