Skip to content
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

Add diag log env variable #3275

Merged
merged 6 commits into from
Jan 25, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 23 additions & 1 deletion src/vstest.console/CommandLine/Executor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ internal int Execute(params string[] args)
{
this.testPlatformEventSource.VsTestConsoleStart();

var isDiag = args != null && args.Any(arg => arg.StartsWith("--diag", StringComparison.OrdinalIgnoreCase));

// If User specifies --nologo via dotnet, do not print splat screen
if (args != null && args.Length !=0 && args.Contains("--nologo"))
{
Expand All @@ -100,7 +102,6 @@ internal int Execute(params string[] args)
}
else
{
var isDiag = args != null && args.Any(arg => arg.StartsWith("--diag", StringComparison.OrdinalIgnoreCase));
this.PrintSplashScreen(isDiag);
}

Expand All @@ -114,6 +115,27 @@ internal int Execute(params string[] args)
exitCode = 1;
}

if (!isDiag)
{
// This takes a path to log directory and log.txt file. Same as the --diag parameter, e.g. VSTEST_DIAG="logs\log.txt"
var diag = Environment.GetEnvironmentVariable("VSTEST_DIAG");
Evangelink marked this conversation as resolved.
Show resolved Hide resolved
nohwnd marked this conversation as resolved.
Show resolved Hide resolved
// This takes Verbose, Info (not Information), Warning, and Error.
var diagVerbosity = Environment.GetEnvironmentVariable("VSTEST_DIAG_VERBOSITY");
if (!string.IsNullOrWhiteSpace(diag))
{
var verbosity = TraceLevel.Verbose;
if (diagVerbosity != null)
{
if (Enum.TryParse<TraceLevel>(diagVerbosity, ignoreCase: true, out var parsedVerbosity))
nohwnd marked this conversation as resolved.
Show resolved Hide resolved
{
verbosity = parsedVerbosity;
}
}

args = args.Concat(new[] { $"--diag:{diag};TraceLevel={verbosity}" }).ToArray();
MarcoRossignoli marked this conversation as resolved.
Show resolved Hide resolved
nohwnd marked this conversation as resolved.
Show resolved Hide resolved
}
}

// Flatten arguments and process response files.
string[] flattenedArguments;
exitCode |= this.FlattenArguments(args, out flattenedArguments);
Expand Down