55using System . Windows ;
66using System . Windows . Controls ;
77using System . Windows . Input ;
8+ using System . Windows . Threading ;
89using NLog ;
10+ using Torch . API ;
911using Torch . Patches ;
1012using MessageBox = System . Windows . Forms . MessageBox ;
1113
@@ -69,6 +71,11 @@ public LogEventViewer()
6971 //set the log level filter to the first item in the combo box
7072 LevelFilterComboBox . SelectedIndex = 0 ;
7173 ClassFilterComboBox . SelectedIndex = 0 ;
74+
75+ if ( TorchServer . Instance . Config . BranchName == TorchBranchType . dev )
76+ {
77+ TestButton . Visibility = Visibility . Visible ;
78+ }
7279 } ;
7380 }
7481
@@ -80,7 +87,7 @@ private void Unloading()
8087 private void LogEvent ( LogEventInfo obj )
8188 {
8289 // Use Dispatcher.Invoke to ensure that the following code block is executed on the UI thread.
83- Dispatcher . Invoke ( ( ) =>
90+ Dispatcher . BeginInvoke ( ( ) =>
8491 {
8592 try
8693 {
@@ -92,14 +99,14 @@ private void LogEvent(LogEventInfo obj)
9299 ClassFilterComboBox . ItemsSource = updatedClassFilters ;
93100 classFilters = updatedClassFilters ; // Ensure classFilters is updated for future checks.
94101 }
95-
102+
96103 AddRow ( obj . Level . ToString ( ) , obj . LoggerName , ( obj . Message == "{0}" ? obj . FormattedMessage : obj . Message ) ) ;
97104 }
98105 catch ( Exception ex )
99106 {
100107 MessageBox . Show ( ex . Message ) ;
101108 }
102- } ) ;
109+ } , DispatcherPriority . Background ) ;
103110 }
104111 private void LevelFilterComboBox_SelectionChanged ( object sender , SelectionChangedEventArgs e )
105112 {
@@ -183,5 +190,10 @@ private void ClearButton_Click(object sender, RoutedEventArgs e)
183190 {
184191 ( ( LogViewModel ) DataContext ) . LogEvents . Clear ( ) ;
185192 }
193+
194+ private void TestButton_OnClickButton_Click ( object sender , RoutedEventArgs e )
195+ {
196+ _log . Error ( "Test error message" ) ;
197+ }
186198 }
187199}
0 commit comments