Skip to content

Commit

Permalink
Rename ShouldLogMessage to LogsMessagesOfImportance
Browse files Browse the repository at this point in the history
  • Loading branch information
ladipro committed May 24, 2021
1 parent 0e059a4 commit f4f4322
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,7 @@ public partial class TaskLoggingHelper : System.MarshalByRefObject
public bool LogMessagesFromFile(string fileName) { throw null; }
public bool LogMessagesFromFile(string fileName, Microsoft.Build.Framework.MessageImportance messageImportance) { throw null; }
public bool LogMessagesFromStream(System.IO.TextReader stream, Microsoft.Build.Framework.MessageImportance messageImportance) { throw null; }
public bool LogsMessagesOfImportance(Microsoft.Build.Framework.MessageImportance importance) { throw null; }
public void LogTelemetry(string eventName, System.Collections.Generic.IDictionary<string, string> properties) { }
public void LogWarning(string message, params object[] messageArgs) { }
public void LogWarning(string subcategory, string warningCode, string helpKeyword, string file, int lineNumber, int columnNumber, int endLineNumber, int endColumnNumber, string message, params object[] messageArgs) { }
Expand All @@ -434,7 +435,6 @@ public partial class TaskLoggingHelper : System.MarshalByRefObject
public void LogWarningWithCodeFromResources(string messageResourceName, params object[] messageArgs) { }
public void LogWarningWithCodeFromResources(string subcategoryResourceName, string file, int lineNumber, int columnNumber, int endLineNumber, int endColumnNumber, string messageResourceName, params object[] messageArgs) { }
public void MarkAsInactive() { }
public bool ShouldLogMessage(Microsoft.Build.Framework.MessageImportance importance) { throw null; }
}
public static partial class ToolLocationHelper
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,7 @@ public partial class TaskLoggingHelper
public bool LogMessagesFromFile(string fileName) { throw null; }
public bool LogMessagesFromFile(string fileName, Microsoft.Build.Framework.MessageImportance messageImportance) { throw null; }
public bool LogMessagesFromStream(System.IO.TextReader stream, Microsoft.Build.Framework.MessageImportance messageImportance) { throw null; }
public bool LogsMessagesOfImportance(Microsoft.Build.Framework.MessageImportance importance) { throw null; }
public void LogTelemetry(string eventName, System.Collections.Generic.IDictionary<string, string> properties) { }
public void LogWarning(string message, params object[] messageArgs) { }
public void LogWarning(string subcategory, string warningCode, string helpKeyword, string file, int lineNumber, int columnNumber, int endLineNumber, int endColumnNumber, string message, params object[] messageArgs) { }
Expand All @@ -275,7 +276,6 @@ public partial class TaskLoggingHelper
public void LogWarningFromResources(string subcategoryResourceName, string warningCode, string helpKeyword, string file, int lineNumber, int columnNumber, int endLineNumber, int endColumnNumber, string messageResourceName, params object[] messageArgs) { }
public void LogWarningWithCodeFromResources(string messageResourceName, params object[] messageArgs) { }
public void LogWarningWithCodeFromResources(string subcategoryResourceName, string file, int lineNumber, int columnNumber, int endLineNumber, int endColumnNumber, string messageResourceName, params object[] messageArgs) { }
public bool ShouldLogMessage(Microsoft.Build.Framework.MessageImportance importance) { throw null; }
}
public static partial class ToolLocationHelper
{
Expand Down
8 changes: 4 additions & 4 deletions src/MSBuild.UnitTests/XMake_Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2281,17 +2281,17 @@ public void EndToEndWarnAsErrors()
}

/// <summary>
/// Helper task used by <see cref="EndToEndMinimumMessageImportance"/> to verify <see cref="TaskLoggingHelper.ShouldLogMessage"/>.
/// Helper task used by <see cref="EndToEndMinimumMessageImportance"/> to verify <see cref="TaskLoggingHelper.LogsMessagesOfImportance"/>.
/// </summary>
public class MessageImportanceCheckingTask : Task
{
public int ExpectedMinimumMessageImportance { get; set; }

public override bool Execute()
{
bool shouldLogHigh = Log.ShouldLogMessage(MessageImportance.High);
bool shouldLogNormal = Log.ShouldLogMessage(MessageImportance.Normal);
bool shouldLogLow = Log.ShouldLogMessage(MessageImportance.Low);
bool shouldLogHigh = Log.LogsMessagesOfImportance(MessageImportance.High);
bool shouldLogNormal = Log.LogsMessagesOfImportance(MessageImportance.Normal);
bool shouldLogLow = Log.LogsMessagesOfImportance(MessageImportance.Low);
return (MessageImportance)ExpectedMinimumMessageImportance switch
{
MessageImportance.High - 1 => !shouldLogHigh && !shouldLogNormal && !shouldLogLow,
Expand Down
10 changes: 5 additions & 5 deletions src/Shared/TaskLoggingHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ public virtual string GetResourceMessage(string resourceName)
/// </summary>
/// <param name="importance">The importance to check.</param>
/// <returns>True if messages of the given importance should be logged, false if it's guaranteed that such messages would be ignored.</returns>
public bool ShouldLogMessage(MessageImportance importance)
public bool LogsMessagesOfImportance(MessageImportance importance)
{
return BuildEngine is not IBuildEngine10 buildEngine10
|| buildEngine10.EngineInterface.LogsMessagesOfImportance(importance);
Expand Down Expand Up @@ -290,7 +290,7 @@ public void LogMessage(MessageImportance importance, string message, params obje
ResourceUtilities.FormatString(message, messageArgs);
}
#endif
if (!ShouldLogMessage(importance))
if (!LogsMessagesOfImportance(importance))
{
return;
}
Expand Down Expand Up @@ -358,7 +358,7 @@ public void LogMessage
// No lock needed, as BuildEngine methods from v4.5 onwards are thread safe.
ErrorUtilities.VerifyThrowArgumentNull(message, nameof(message));

if (!ShouldLogMessage(importance))
if (!LogsMessagesOfImportance(importance))
{
return;
}
Expand Down Expand Up @@ -490,7 +490,7 @@ public void LogMessageFromResources(MessageImportance importance, string message
// global state.
ErrorUtilities.VerifyThrowArgumentNull(messageResourceName, nameof(messageResourceName));

if (!ShouldLogMessage(importance))
if (!LogsMessagesOfImportance(importance))
{
return;
}
Expand Down Expand Up @@ -577,7 +577,7 @@ public void LogCommandLine(MessageImportance importance, string commandLine)
// No lock needed, as BuildEngine methods from v4.5 onwards are thread safe.
ErrorUtilities.VerifyThrowArgumentNull(commandLine, nameof(commandLine));

if (!ShouldLogMessage(importance))
if (!LogsMessagesOfImportance(importance))
{
return;
}
Expand Down
6 changes: 3 additions & 3 deletions src/Tasks/AssemblyDependency/ResolveAssemblyReference.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1248,7 +1248,7 @@ List<Exception> generalResolutionExceptions

#if FEATURE_WIN32_REGISTRY
MessageImportance messageImportance = MessageImportance.Low;
if (dependencyTable.Resolvers != null && Log.ShouldLogMessage(messageImportance))
if (dependencyTable.Resolvers != null && Log.LogsMessagesOfImportance(messageImportance))
{
foreach (Resolver r in dependencyTable.Resolvers)
{
Expand Down Expand Up @@ -1347,7 +1347,7 @@ private void LogReference(Reference reference, string fusionName)
{
// Set an importance level to be used for secondary messages.
MessageImportance importance = ChooseReferenceLoggingImportance(reference);
if (!Log.ShouldLogMessage(importance))
if (!Log.LogsMessagesOfImportance(importance))
{
return;
}
Expand Down Expand Up @@ -1418,7 +1418,7 @@ private MessageImportance ChooseReferenceLoggingImportance(Reference reference)
private void LogInputs()
{
MessageImportance importance = MessageImportance.Low;
if (Traits.Instance.EscapeHatches.LogTaskInputs || Silent || !Log.ShouldLogMessage(importance))
if (Traits.Instance.EscapeHatches.LogTaskInputs || Silent || !Log.LogsMessagesOfImportance(importance))
{
// the inputs will be logged automatically anyway, avoid duplication in the logs
return;
Expand Down

0 comments on commit f4f4322

Please sign in to comment.