Skip to content

Instantly share code, notes, and snippets.

@JayBazuzi
Last active December 28, 2015 14:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JayBazuzi/7519004 to your computer and use it in GitHub Desktop.
Save JayBazuzi/7519004 to your computer and use it in GitHub Desktop.
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