Skip to content

Instantly share code, notes, and snippets.

@slippycheeze
Created November 23, 2022 10:30
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 slippycheeze/8e8b24b4fc70abc6c8fd2851f18fe5ae to your computer and use it in GitHub Desktop.
Save slippycheeze/8e8b24b4fc70abc6c8fd2851f18fe5ae to your computer and use it in GitHub Desktop.
protected static void OnAfterExecute(NMS.Script.ModFiles modfiles, CancellationToken cancel) {
// gather all the warnings and above from the log
var alerts = modfiles.ExecuteLog
.Where(item => item.Type == LogItemType.Warning || item.Type == LogItemType.Failure)
.ToList();
if (alerts.Any()) {
int warnings = alerts.Where(item => item.Type == LogItemType.Warning).Count();
int errors = alerts.Where(item => item.Type == LogItemType.Failure).Count();
var heading = new StringBuilder("—————< ");
if (warnings > 0) heading.AppendFormat("{0} WARNINGS", warnings);
if (warnings > 0 && errors > 0) heading.Append(" AND ");
if (errors > 0) heading.AppendFormat("{0} ERRORS", errors);
heading.Append(" >—————");
modfiles.ExecuteLog.AddHeading(heading.ToString());
foreach (var alert in alerts)
modfiles.ExecuteLog.Add(alert);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment