Can Chrome\'s built-in JavaScript console display colors?
I want errors in red, warnings in orange and console.log
\'s in green. Is that possible?
I doubt that anyone will actually see it but I have a simple solution for those who want to mix several colors in the same line:
export enum Colors {
Black = '\033[30m',
Red = '\x1b[31m',
Green = '\x1b[32m',
Yellow = '\x1b[33m',
Blue = '\033[34m',
Magenta = '\033[35m',
Cyan = '\033[36m',
White = '\033[37m'
}
function color(text: string, color: color: Colors) {
return `${color}${text}\x1b[0m`;
}
console.log(`This is ${color('green text', Colors.Green)} but this is black. This is red ${color('red', Colors.Red)} etc`);