-
Notifications
You must be signed in to change notification settings - Fork 325
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
Added Level as prefix for loggers. #967
Conversation
@@ -46,7 +48,7 @@ public void CleanUp() | |||
public void OutputErrorForSimpleMessageShouldOutputTheMessageString() | |||
{ | |||
this.mockOutput.Object.Error("HelloError", null); | |||
this.mockOutput.Verify(o => o.WriteLine("HelloError", OutputLevel.Error), Times.Once()); | |||
this.mockOutput.Verify(o => o.WriteLine("Error: HelloError", OutputLevel.Error), Times.Once()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we use Resources.CommandLineError
here?
@@ -26,7 +24,7 @@ public static void Error(this IOutput output, string format, params object[] arg | |||
{ | |||
SetColorForAction(ConsoleColor.Red, () => | |||
{ | |||
Output(output, OutputLevel.Error, DefaultFormat, format, args); | |||
Output(output, OutputLevel.Error, Resources.CommandLineError, format, args); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this is a backward compatibility fix (it hides errors for the user, and that's the reason it was removed for newer experience), suggest to use a console logger parameter for this. E.g. /logger:console;prefix=true
. This will keep the default behavior strict.
@dotnet-bot test this please. |
@@ -15,6 +15,13 @@ namespace Microsoft.VisualStudio.TestPlatform.Utilities | |||
public static class OutputExtensions | |||
{ | |||
/// <summary> | |||
/// Bool to decide whether Verbose level should be added as prefix or not in log messages. | |||
/// </summary> | |||
internal static bool AppendPrefix; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure if an Extension methods unit should contain state or configuration.
var prefixExists = parameters.TryGetValue(ConsoleLogger.PrefixParam, out string prefix); | ||
if (prefixExists) | ||
{ | ||
bool.TryParse(prefix, out OutputExtensions.AppendPrefix); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this returns false, we don't need to log?
[TestMethod] | ||
public void OutputErrorForSimpleMessageShouldOutputTheMessageStringWithPrefixIfSet() | ||
{ | ||
OutputExtensions.AppendPrefix = true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to validate other scenarios? Can it be a data driven test?
/// <summary> | ||
/// Bool to decide whether Verbose level should be added as prefix or not in log messages. | ||
/// </summary> | ||
internal static bool AppendPrefix; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if an extension methods class should have state.
Having prefix=true always makes finding warning and error messages easy, especially output is redirect to files in CI/CD scenarios. Currently user can identify the level of message by color of message in console which we loss once it redirect to file. Update help for |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add doc in vstest-docs.
Added Level as prefix for loggers.