diff --git a/src/Core/Diagnostics.cs b/src/Core/Diagnostics.cs index c10733ab..b0626bc3 100644 --- a/src/Core/Diagnostics.cs +++ b/src/Core/Diagnostics.cs @@ -112,13 +112,25 @@ namespace CppSharp Level = DiagnosticKind.Message; } + private string GetColorForDiagKind(DiagnosticKind kind) => + kind switch + { + DiagnosticKind.Debug => null, + DiagnosticKind.Message => null, + DiagnosticKind.Warning => "\u001b[33m", // yellow + DiagnosticKind.Error => "\u001b[91m", // red + _ => null + }; + public void Emit(DiagnosticInfo info) { if (info.Kind < Level) return; var currentIndentation = Indents.Sum(); - var message = new string(' ', currentIndentation) + info.Message; + var colorString = GetColorForDiagKind(info.Kind); + var colorReset = colorString == null ? null : "\u001b[0m"; + var message = $"{new string(' ', currentIndentation)}{colorString}{info.Message}{colorReset}"; if (info.Kind == DiagnosticKind.Error) {