@@ -23,6 +23,7 @@ namespace Rubberduck
23
23
{
24
24
public sealed class App : IDisposable
25
25
{
26
+ private const string FILE_TARGET_NAME = "file" ;
26
27
private readonly VBE _vbe ;
27
28
private readonly IMessageBox _messageBox ;
28
29
private readonly IRubberduckParser _parser ;
@@ -41,7 +42,7 @@ public sealed class App : IDisposable
41
42
private readonly IConnectionPoint _projectsEventsConnectionPoint ;
42
43
private readonly int _projectsEventsCookie ;
43
44
44
- private readonly IDictionary < string , Tuple < IConnectionPoint , int > > _componentsEventsConnectionPoints =
45
+ private readonly IDictionary < string , Tuple < IConnectionPoint , int > > _componentsEventsConnectionPoints =
45
46
new Dictionary < string , Tuple < IConnectionPoint , int > > ( ) ;
46
47
private readonly IDictionary < string , Tuple < IConnectionPoint , int > > _referencesEventsConnectionPoints =
47
48
new Dictionary < string , Tuple < IConnectionPoint , int > > ( ) ;
@@ -74,7 +75,7 @@ public App(VBE vbe, IMessageBox messageBox,
74
75
75
76
_sink = new VBProjectsEventsSink ( ) ;
76
77
var connectionPointContainer = ( IConnectionPointContainer ) _vbe . VBProjects ;
77
- var interfaceId = typeof ( _dispVBProjectsEvents ) . GUID ;
78
+ var interfaceId = typeof ( _dispVBProjectsEvents ) . GUID ;
78
79
connectionPointContainer . FindConnectionPoint ( ref interfaceId , out _projectsEventsConnectionPoint ) ;
79
80
80
81
_sink . ProjectAdded += sink_ProjectAdded ;
@@ -130,9 +131,32 @@ private bool ShouldEvaluateCanExecute(Declaration selectedDeclaration, ParserSta
130
131
131
132
private void _configService_SettingsChanged ( object sender , EventArgs e )
132
133
{
134
+ _config = _configService . LoadConfiguration ( ) ;
133
135
// also updates the ShortcutKey text
134
136
_appMenus . Localize ( ) ;
135
137
_hooks . HookHotkeys ( ) ;
138
+ UpdateLoggingLevel ( ) ;
139
+ }
140
+
141
+ private void UpdateLoggingLevel ( )
142
+ {
143
+ var fileRule = LogManager . Configuration . LoggingRules . Where ( rule => rule . Targets . Any ( t => t . Name == FILE_TARGET_NAME ) ) . FirstOrDefault ( ) ;
144
+ if ( fileRule == null )
145
+ {
146
+ return ;
147
+ }
148
+ if ( _config . UserSettings . GeneralSettings . DetailedLoggingEnabled )
149
+ {
150
+ // "Enable" should have been called "Add" perhaps?
151
+ fileRule . EnableLoggingForLevel ( LogLevel . Trace ) ;
152
+ fileRule . EnableLoggingForLevel ( LogLevel . Debug ) ;
153
+ }
154
+ else
155
+ {
156
+ fileRule . DisableLoggingForLevel ( LogLevel . Trace ) ;
157
+ fileRule . DisableLoggingForLevel ( LogLevel . Debug ) ;
158
+ }
159
+ LogManager . ReconfigExistingLoggers ( ) ;
136
160
}
137
161
138
162
public void Startup ( )
@@ -142,6 +166,7 @@ public void Startup()
142
166
_appMenus . Localize ( ) ;
143
167
Task . Delay ( 1000 ) . ContinueWith ( t => UiDispatcher . Invoke ( ( ) => _parser . State . OnParseRequested ( this ) ) ) . ConfigureAwait ( false ) ;
144
168
_hooks . HookHotkeys ( ) ;
169
+ UpdateLoggingLevel ( ) ;
145
170
}
146
171
147
172
public void Shutdown ( )
@@ -186,10 +211,10 @@ async void sink_ProjectRemoved(object sender, DispatcherEventArgs<VBProject> e)
186
211
}
187
212
}
188
213
189
- private readonly IDictionary < string , VBComponentsEventsSink > _componentsEventsSinks =
190
- new Dictionary < string , VBComponentsEventsSink > ( ) ;
214
+ private readonly IDictionary < string , VBComponentsEventsSink > _componentsEventsSinks =
215
+ new Dictionary < string , VBComponentsEventsSink > ( ) ;
191
216
192
- private readonly IDictionary < string , ReferencesEventsSink > _referencesEventsSinks =
217
+ private readonly IDictionary < string , ReferencesEventsSink > _referencesEventsSinks =
193
218
new Dictionary < string , ReferencesEventsSink > ( ) ;
194
219
195
220
async void sink_ProjectAdded ( object sender , DispatcherEventArgs < VBProject > e )
@@ -226,7 +251,7 @@ private void RegisterComponentsEventSink(VBComponents components, string project
226
251
}
227
252
228
253
var connectionPointContainer = ( IConnectionPointContainer ) components ;
229
- var interfaceId = typeof ( _dispVBComponentsEvents ) . GUID ;
254
+ var interfaceId = typeof ( _dispVBComponentsEvents ) . GUID ;
230
255
231
256
IConnectionPoint connectionPoint ;
232
257
connectionPointContainer . FindConnectionPoint ( ref interfaceId , out connectionPoint ) ;
@@ -436,7 +461,7 @@ public void Dispose()
436
461
}
437
462
438
463
if ( _autoSave != null )
439
- {
464
+ {
440
465
_autoSave . Dispose ( ) ;
441
466
_autoSave = null ;
442
467
}
0 commit comments