-
Notifications
You must be signed in to change notification settings - Fork 392
Improve in-proc collector logs #552
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,9 +1,9 @@ | ||
| using System; | ||
| using System.Reflection; | ||
|
|
||
| using coverlet.collector.Resources; | ||
| using Coverlet.Collector.Utilities; | ||
| using Coverlet.Core.Instrumentation; | ||
| using Microsoft.VisualStudio.TestPlatform.ObjectModel; | ||
| using Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollection; | ||
| using Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollector.InProcDataCollector; | ||
| using Microsoft.VisualStudio.TestPlatform.ObjectModel.InProcDataCollector; | ||
|
|
@@ -12,8 +12,12 @@ namespace Coverlet.Collector.DataCollection | |
| { | ||
| public class CoverletInProcDataCollector : InProcDataCollection | ||
| { | ||
| private TestPlatformEqtTrace _eqtTrace; | ||
|
|
||
| public void Initialize(IDataCollectionSink dataCollectionSink) | ||
| { | ||
| _eqtTrace = new TestPlatformEqtTrace(); | ||
| _eqtTrace.Verbose("Initialize CoverletInProcDataCollector"); | ||
| } | ||
|
|
||
| public void TestCaseEnd(TestCaseEndArgs testCaseEndArgs) | ||
|
|
@@ -36,17 +40,14 @@ public void TestSessionEnd(TestSessionEndArgs testSessionEndArgs) | |
|
|
||
| try | ||
| { | ||
| _eqtTrace.Verbose($"Calling ModuleTrackerTemplate.UnloadModule for '{injectedInstrumentationClass.Assembly.FullName}'"); | ||
| var unloadModule = injectedInstrumentationClass.GetMethod(nameof(ModuleTrackerTemplate.UnloadModule), new[] { typeof(object), typeof(EventArgs) }); | ||
| unloadModule.Invoke(null, new[] { null, EventArgs.Empty }); | ||
| _eqtTrace.Verbose($"Called ModuleTrackerTemplate.UnloadModule for '{injectedInstrumentationClass.Assembly.FullName}'"); | ||
| } | ||
| catch (Exception ex) | ||
| { | ||
| // Throw any exception if unload fails | ||
| if (EqtTrace.IsErrorEnabled) | ||
| { | ||
| EqtTrace.Error("{0}: Failed to unload module with error: {1}", CoverletConstants.InProcDataCollectorName, ex); | ||
| } | ||
|
|
||
| _eqtTrace.Error("{0}: Failed to unload module with error: {1}", CoverletConstants.InProcDataCollectorName, ex); | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @vagisha-nidhi I removed check
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @vagisha-nidhi I merged...let me know if it's a problem. |
||
| string errorMessage = string.Format(Resources.FailedToUnloadModule, CoverletConstants.InProcDataCollectorName); | ||
| throw new CoverletDataCollectorException(errorMessage, ex); | ||
| } | ||
|
|
@@ -57,7 +58,7 @@ public void TestSessionStart(TestSessionStartArgs testSessionStartArgs) | |
| { | ||
| } | ||
|
|
||
| private static Type GetInstrumentationClass(Assembly assembly) | ||
| private Type GetInstrumentationClass(Assembly assembly) | ||
| { | ||
| try | ||
| { | ||
|
|
@@ -74,11 +75,7 @@ private static Type GetInstrumentationClass(Assembly assembly) | |
| } | ||
| catch (Exception ex) | ||
| { | ||
| // Avoid crashing if reflection fails. | ||
| if (EqtTrace.IsWarningEnabled) | ||
| { | ||
| EqtTrace.Warning("{0}: Failed to get Instrumentation class with error: {1}", CoverletConstants.InProcDataCollectorName, ex); | ||
| } | ||
| _eqtTrace.Warning("{0}: Failed to get Instrumentation class with error: {1}", CoverletConstants.InProcDataCollectorName, ex); | ||
| return null; | ||
| } | ||
| } | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.