Skip to content

Commit

Permalink
[LiveLogger] Add code to high priority messages (#8397)
Browse files Browse the repository at this point in the history
Fixes #8393

Context
Currently the live logger does not log the message id's. Including the message ID is useful when searching for messages from customer reports.

Changes Made
When receiving BuildMessageEventArgs, the Code is now also passed to MessageNode and printed on the display.
  • Loading branch information
edvilme authored Feb 7, 2023
1 parent 76215a0 commit e1b3bf9
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/MSBuild/LiveLogger/MessageNode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,19 @@ public MessageNode(LazyFormattedBuildEventArgs args)
// Get type
switch (args)
{
case BuildMessageEventArgs:
case BuildMessageEventArgs message:
// Detect output messages
var finalOutputMarker = " -> ";
int i = args.Message!.IndexOf(finalOutputMarker, StringComparison.Ordinal);
int i = message.Message!.IndexOf(finalOutputMarker, StringComparison.Ordinal);
if (i > 0)
{
Type = MessageType.ProjectOutputMessage;
ProjectOutputExecutablePath = args.Message!.Substring(i + finalOutputMarker.Length);
ProjectOutputExecutablePath = message.Message!.Substring(i + finalOutputMarker.Length);
}
else
{
Type = MessageType.HighPriorityMessage;
Code = message.Subcategory;
}
break;
case BuildWarningEventArgs warning:
Expand Down Expand Up @@ -84,7 +85,7 @@ public string ToANSIString()
return $"⚙️ {ANSIBuilder.Formatting.Hyperlink(ProjectOutputExecutablePath!, Path.GetDirectoryName(ProjectOutputExecutablePath)!)}";
case MessageType.HighPriorityMessage:
default:
return $"ℹ️ {ANSIBuilder.Formatting.Italic(Message)}";
return $"ℹ️ {Code}{(Code is not null ? ": " : string.Empty)} {ANSIBuilder.Formatting.Italic(Message)}";
}
}

Expand Down

0 comments on commit e1b3bf9

Please sign in to comment.