File tree Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -112,13 +112,25 @@ public ConsoleDiagnostics()
112112 Level = DiagnosticKind . Message ;
113113 }
114114
115+ private string GetColorForDiagKind ( DiagnosticKind kind ) =>
116+ kind switch
117+ {
118+ DiagnosticKind . Debug => null ,
119+ DiagnosticKind . Message => null ,
120+ DiagnosticKind . Warning => "\u001b [33m" , // yellow
121+ DiagnosticKind . Error => "\u001b [91m" , // red
122+ _ => null
123+ } ;
124+
115125 public void Emit ( DiagnosticInfo info )
116126 {
117127 if ( info . Kind < Level )
118128 return ;
119129
120130 var currentIndentation = Indents . Sum ( ) ;
121- var message = new string ( ' ' , currentIndentation ) + info . Message ;
131+ var colorString = GetColorForDiagKind ( info . Kind ) ;
132+ var colorReset = colorString == null ? null : "\u001b [0m" ;
133+ var message = $ "{ new string ( ' ' , currentIndentation ) } { colorString } { info . Message } { colorReset } ";
122134
123135 if ( info . Kind == DiagnosticKind . Error )
124136 {
You can’t perform that action at this time.
0 commit comments