Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 674 Vote(s) - 3.43 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Visual Studio Code Debug Console colors?

#11
console.log("\u001b[1;32m" + 'This is your message!!!' + "\u001b[0m"); //Green message with escape

console.log("\u001b[1;31m" + 'This is your message!!!' + "\u001b[0m"); //Red message with escape
Reply

#12
Here's a little utility I wrote based on the answers here (and some googling):

```js
export const colored_console = {
/**
* @param color red | green | yellow | blue | purple | cyan | red_bg | green_bg | blue_bg | purple_bg | cyan_bg | yellow_bg | white_bg
* @param args things you want to log
*/
log: function(color, ...args) {
// adjust text color
if (color === 'red' ) { console.log(`\u001b[31m`, ...args, `\u001b[0m`) }
else if (color === 'green' ) { console.log(`\u001b[32m`, ...args, `\u001b[0m`) }
else if (color === 'yellow' ) { console.log(`\u001b[33m`, ...args, `\u001b[0m`) }
else if (color === 'blue' ) { console.log(`\u001b[34m`, ...args, `\u001b[0m`) }
else if (color === 'purple' ) { console.log(`\u001b[35m`, ...args, `\u001b[0m`) }
else if (color === 'cyan' ) { console.log(`\u001b[36m`, ...args, `\u001b[0m`) }
// adjust bg color
else if (color === 'red_bg' ) { console.log(`\u001b[41m`, ...args, `\u001b[0m`) }
else if (color === 'blue_bg' ) { console.log(`\u001b[44m`, ...args, `\u001b[0m`) }
else if (color === 'purple_bg') { console.log(`\u001b[45m`, ...args, `\u001b[0m`) }
else if (color === 'cyan_bg' ) { console.log(`\u001b[46m`, ...args, `\u001b[0m`) }
// adjust text and bg color for better visibility
else if (color === 'green_bg' ) { console.log(`\u001b[42m\u001b[34m`, ...args, `\u001b[0m`) }
else if (color === 'yellow_bg') { console.log(`\u001b[43m\u001b[34m`, ...args, `\u001b[0m`) }
else if (color === 'white_bg' ) { console.log(`\u001b[47m\u001b[34m`, ...args, `\u001b[0m`) }
// if you didn't specify a color, log everything with default color
else { console.log(color, ...args) }
}
}
```

...and here's some further reading I found useful:

[Google Search: ANSI colors][1] (check out the image results)

[Wikipedia: ANSI escape code][2]


[1]: https://www.google.com/search?q=ANSI%20colors
[2]:

[To see links please register here]

Reply

#13
See @

[To see links please register here]

for lore and roleplay.

Here is just a no brain answer.

||Versions|
|-|-|
|Tested up to|Visual Studio Code May 2021 (version `1.63`)|

### Text

```
console.log( "\u001b[1;31m Red message" );
console.log( "\u001b[1;32m Green message" );
console.log( "\u001b[1;33m Yellow message" );
console.log( "\u001b[1;34m Blue message" );
console.log( "\u001b[1;35m Purple message" );
console.log( "\u001b[1;36m Cyan message" );
```

### Background

```
console.log( "\u001b[1;41m Red background" );
console.log( "\u001b[1;42m Green background" );
console.log( "\u001b[1;43m Yellow background" );
console.log( "\u001b[1;44m Blue background" );
console.log( "\u001b[1;45m Purple background" );
console.log( "\u001b[1;46m Cyan background" );
```

### Reset

```
console.log( "\u001b[0m Reset text and background color/style to default" );
```

### Example

```
console.log( "\u001b[1;31m --process: Error" + "\u001b[0m" );
```
Reply

#14
I was trying to customize the colors for `console.debug()` statements because I am typically using `console.info()` (and higher) statements in production code, whereas unit tests use `console.debug()` for additional analytic information.

Unfortunately, Javascript considers `console.info()` and `console.debug()` essentially the same. Only some browsers will suppress `console.debug()`. Visual Studio Code also does not provide a separate option to configure a different color for debug-level output.

However, a few other responses on SO to this and other posts let me to this simple solution to print `console.debug()` statements in a different color.
```
const PURPLE = "\u001b[35m";
const consoleDebugOrig = console.debug;
console.debug = function (...args) {
consoleDebugOrig(PURPLE, ...args, PURPLE);
};
```
You could even use this approach to apply other types of formatting to debug outputs, like indentation or prefixes.
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through