question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

We need a way to customize output color for error/warning, etc

See original GitHub issue

Specifically, in PowerShell.exe we have the ability to change the color used for errors, warnings, etc.:

C:\PS> $Host.PrivateData                                                    
                                      
ErrorForegroundColor    : DarkRed     
ErrorBackgroundColor    : Black       
WarningForegroundColor  : Yellow      
WarningBackgroundColor  : Black       
DebugForegroundColor    : Green       
DebugBackgroundColor    : Black       
VerboseForegroundColor  : Cyan        
VerboseBackgroundColor  : Black       
ProgressForegroundColor : DarkMagenta 
ProgressBackgroundColor : Gray        

In VSCode I can change the colors of the 16 ANSI colors, but I can’t find a way to change which of them you are using to write errors out.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:2
  • Comments:23 (22 by maintainers)

github_iconTop GitHub Comments

3reactions
SeeminglySciencecommented, Apr 11, 2018

If anyone is interested in picking this up the general idea is to

  1. Port ConsoleColorProxy and the PrivateData member from ConsoleHost in pwsh to EditorServicesPSHost.PrivateData

  2. Change the Write* methods in EditorServicesPSHostUserInterface to use the new colors

1reaction
KeroroLulucommented, Apr 20, 2018

@tylerl0706 Well I changed it in EditorServicesPSHostInterface

public ConsoleColor ErrorForegroundColor { get; set; } = ConsoleColor.DarkCyan;

But it doesn’t change in my pwsh

Here’s my WriteOutput

public override void WriteErrorLine(string value)
        {
            this.WriteOutput(
                value,
                true,
                OutputType.Error,
                foregroundColor: this.ErrorForegroundColor,
                backgroundColor: this.ErrorBackgroundColor);
        }

I did my Invoke-Build Build and there’s no error

Edit

It’s really strange, I change my WriteOutput

public override void WriteErrorLine(string value)
        {
            this.WriteOutput(
                value,
                true,
                OutputType.Error,
                foregroundColor: ConsoleColor.DarkCyan,
                backgroundColor: this.ErrorBackgroundColor);
        }

But my error foreground color is still red !

Edit 2

Nevermind !! It works that was just a little problem from my installation 😃

I will do the Pull Request !

Read more comments on GitHub >

github_iconTop Results From Across the Web

Please change the color of error output · Issue #7451
I have attached a picture with the change in error color from ... it is hard to reliably decide whether something is an...
Read more >
Can I change the color of text from PUT statement without ...
But I was wondering if there's a way I can control the color of the resulting text in the log to be something...
Read more >
How to configure console log to recognize error/warn/info ...
I see in IntelliJ's preferences, under Editor > Color Scheme > Console Colors, that you can configure colors for Error, Warning, Info, etc....
Read more >
How to change the color of the PowerShell ISE editor using ...
To change the color of the ISE Editor, we need to use $psISE cmdlet which is only available for the ISE editor. Now...
Read more >
Make Your PowerShell Errors Less Harsh By Changing Their ...
The answer to how to change the color of the error message lies in PrivateData property of $host (which is an automatic variable...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found