loading...

re: NodeJS: How To Colorize Text VIEW POST

TOP OF THREAD FULL DISCUSSION
re: My favourite way is escaping symbols instead of downloading a pkg to get extra free mb. Example: const reset = '\x1b[0m' export const blue = ms...
 

I recently used the same thing to have color-coded logging on my node app :)

looks a little something like this:

function debug(message) {
    const timestamp = new Date().toString()
    console.log('\x1b[36m%s\x1b[0m', `${timestamp} - ${message}`)
}

function error(message) {
    const timestamp = new Date().toString()
    console.error('\x1b[31m%s\x1b[0m', `${timestamp} - ${message}`)
}
 

Hey v 1 r t l & Andre,

thanks for your tips,
I will have a look at it.

If anyone is interested in further information:
various escape codes
bigger discussion on stackoverflow

code of conduct - report abuse