Skip to content

Commit f11b16d

Browse files
committed
logging tweaks
1 parent febdcf0 commit f11b16d

File tree

5 files changed

+26
-15
lines changed

5 files changed

+26
-15
lines changed

Rubberduck.CodeAnalysis/Inspections/Abstract/InspectionBase.cs

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,14 @@ public IEnumerable<IInspectionResult> GetInspectionResults(CancellationToken tok
8383
.Where(ir => !ir.IsIgnoringInspectionResult(finder))
8484
.ToList();
8585
stopwatch.Stop();
86-
Logger.Trace("Intercepted invocation of '{0}.{1}' returned {2} objects.", GetType().Name, nameof(DoGetInspectionResults), result.Count);
87-
Logger.Trace("Intercepted invocation of '{0}.{1}' ran for {2}ms", GetType().Name, nameof(DoGetInspectionResults), stopwatch.ElapsedMilliseconds);
86+
if (result.Count > 0)
87+
{
88+
Logger.Trace("'Returned {2} results, completed in {3}ms.", result.Count, stopwatch.ElapsedMilliseconds);
89+
}
90+
else
91+
{
92+
Logger.Trace("Completed in {2}ms", stopwatch.ElapsedMilliseconds);
93+
}
8894
return result;
8995
}
9096

@@ -103,8 +109,14 @@ public IEnumerable<IInspectionResult> GetInspectionResults(QualifiedModuleName m
103109
.Where(ir => !ir.IsIgnoringInspectionResult(finder))
104110
.ToList();
105111
stopwatch.Stop();
106-
Logger.Trace("Intercepted invocation of '{0}.{1}' returned {2} objects.", GetType().Name, nameof(DoGetInspectionResults), result.Count);
107-
Logger.Trace("Intercepted invocation of '{0}.{1}' ran for {2}ms", GetType().Name, nameof(DoGetInspectionResults), stopwatch.ElapsedMilliseconds);
112+
if (result.Count > 0)
113+
{
114+
Logger.Trace("'Returned {2} results, completed in {3}ms.", result.Count, stopwatch.ElapsedMilliseconds);
115+
}
116+
else
117+
{
118+
Logger.Trace("Completed in {2}ms", stopwatch.ElapsedMilliseconds);
119+
}
108120
return result;
109121
}
110122

Rubberduck.Core/UI/Inspections/InspectionResultsViewModel.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -506,7 +506,7 @@ private async Task RefreshInspections_Internal(CancellationToken token)
506506
}
507507

508508
stopwatch.Stop();
509-
Logger.Trace("Inspection results returned in {0}ms", stopwatch.ElapsedMilliseconds);
509+
Logger.Trace("Returned {0} inspection results in {1}ms", results.Count, stopwatch.ElapsedMilliseconds);
510510

511511
_uiDispatcher.Invoke(() =>
512512
{
@@ -533,7 +533,7 @@ private async Task RefreshInspections_Internal(CancellationToken token)
533533
}
534534

535535
stopwatch.Stop();
536-
Logger.Trace("Inspection results rendered in {0}ms", stopwatch.ElapsedMilliseconds);
536+
Logger.Trace("Rendering completed in {0}ms", stopwatch.ElapsedMilliseconds);
537537
});
538538
}
539539

Rubberduck.Parsing/VBA/ParseCoordinator.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -463,18 +463,18 @@ private void ParseAll(object requestor)
463463
Monitor.Enter(ParsingRunSyncObject, ref lockTaken);
464464

465465
watch = Stopwatch.StartNew();
466-
Logger.Debug("Parsing run started. (thread {0}).", Thread.CurrentThread.ManagedThreadId);
466+
Logger.Debug("Parsing run started on thread {0}.", Thread.CurrentThread.ManagedThreadId);
467467

468468
ParseAllInternal(requestor, token);
469469
}
470470
catch (OperationCanceledException)
471471
{
472472
//This is the point to which the cancellation should break.
473-
Logger.Debug("Parsing run got canceled. (thread {0}).", Thread.CurrentThread.ManagedThreadId);
473+
Logger.Debug("Parsing run was cancelled on thread {0}.", Thread.CurrentThread.ManagedThreadId);
474474
}
475475
catch (Exception exception)
476476
{
477-
Logger.Error(exception, "Unexpected exception thrown in parsing run. (thread {0}).", Thread.CurrentThread.ManagedThreadId);
477+
Logger.Error(exception, "Unexpected exception thrown in parsing run on thread {0}.", Thread.CurrentThread.ManagedThreadId);
478478
if (_parserStateManager.OverallParserState != ParserState.UnexpectedError)
479479
{
480480
_parserStateManager.SetStatusAndFireStateChanged(this, ParserState.UnexpectedError, token);
@@ -489,7 +489,7 @@ private void ParseAll(object requestor)
489489
ParsingSuspendLock.ExitReadLock();
490490
}
491491
}
492-
if (watch != null) Logger.Info("Parsing run finished after {0}s. (thread {1}).", watch.Elapsed.TotalSeconds, Thread.CurrentThread.ManagedThreadId);
492+
if (watch != null) Logger.Info("Parsing run on thread {0} completed in {1}ms.", Thread.CurrentThread.ManagedThreadId, watch.ElapsedMilliseconds);
493493
}
494494

495495
protected void ParseAllInternal(object requestor, CancellationToken token)

Rubberduck.Parsing/VBA/ReferenceManagement/ReferenceResolveRunnerBase.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ protected void ResolveReferences(DeclarationFinder finder, QualifiedModuleName m
182182
{
183183
token.ThrowIfCancellationRequested();
184184

185-
Logger.Debug("Resolving identifier references in '{0}'... (thread {1})", module.Name, Thread.CurrentThread.ManagedThreadId);
185+
Logger.Debug("Thread {0} is resolving identifier references in component '{1}'.", Thread.CurrentThread.ManagedThreadId, module.Name);
186186

187187
var resolver = new IdentifierReferenceResolver(module, finder);
188188
var listener = new IdentifierReferenceListener(resolver);
@@ -195,8 +195,7 @@ protected void ResolveReferences(DeclarationFinder finder, QualifiedModuleName m
195195
var watch = Stopwatch.StartNew();
196196
walker.Walk(listener, tree);
197197
watch.Stop();
198-
Logger.Debug("Binding resolution done for component '{0}' in {1}ms (thread {2})", module.Name,
199-
watch.ElapsedMilliseconds, Thread.CurrentThread.ManagedThreadId);
198+
Logger.Debug("Thread {0} completed binding resolution for component '{1}' in {2}ms", Thread.CurrentThread.ManagedThreadId, module.Name, watch.ElapsedMilliseconds);
200199

201200
//Evaluation of the overall status has to be deferred to allow processing of undeclared variables before setting the ready state.
202201
_parserStateManager.SetModuleState(module, ParserState.Ready, token, false);

Rubberduck.Parsing/VBA/RubberduckParserState.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ private void OnStateChanged(object requestor, CancellationToken token, ParserSta
342342
{
343343
Interlocked.Increment(ref _stateChangedInvocations);
344344

345-
Logger.Info($"{nameof(RubberduckParserState)} ({_stateChangedInvocations}) is invoking {nameof(StateChanged)} ({Status})");
345+
Logger.Info($"{nameof(RubberduckParserState)}.{nameof(StateChanged)} invocation {_stateChangedInvocations} sets status to '{Status}'.");
346346

347347
var highPriorityHandler = StateChangedHighPriority;
348348
if (highPriorityHandler != null && !token.IsCancellationRequested)
@@ -423,7 +423,7 @@ public void SetModuleState(QualifiedModuleName module, ParserState state, Cancel
423423

424424
_moduleStates.AddOrUpdate(module, new ModuleState(state), (c, e) => e.SetState(state));
425425
_moduleStates.AddOrUpdate(module, new ModuleState(parserError), (c, e) => e.SetModuleException(parserError));
426-
Logger.Debug("Module '{0}' state is changing to '{1}' (thread {2})", module.ComponentName, state, Thread.CurrentThread.ManagedThreadId);
426+
Logger.Debug("Thread {0} is changing state of module '{1}' to '{2}'.", Thread.CurrentThread.ManagedThreadId, module.ComponentName, state);
427427
OnModuleStateChanged(module, state, oldState, token);
428428
if (evaluateOverallState)
429429
{

0 commit comments

Comments
 (0)