Created
November 23, 2022 10:30
-
-
Save slippycheeze/8e8b24b4fc70abc6c8fd2851f18fe5ae to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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