Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Custom MSBuild logger - grabs only High importance messages, returns them as a string.
class HighImportanceStringLogger : ILogger
{
readonly private StringBuilder stringBuilder = new StringBuilder();
public void Initialize(IEventSource eventSource)
{
eventSource.MessageRaised += eventSource_MessageRaised;
}
void eventSource_MessageRaised(object sender, BuildMessageEventArgs e)
{
if (e.Importance <= MessageImportance.High)
{
stringBuilder.AppendLine(e.Message);
}
}
public string Parameters { get; set; }
public void Shutdown() { }
public LoggerVerbosity Verbosity { get; set; }
public override string ToString()
{
return this.stringBuilder.ToString();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment