Colors in my server-side `console.log()` while Meteor is in development mode

I’d like to make use of this nifty npm colors package when printing to the server side console while running my meteor server.

I’m generating quite a bit of fixture data that I’d like to be able to color code to make it easier to read in the console.

I’ve tried both:

import colors from 'colors/safe'
console.log(colors.red("Generating Fake Data:"))

and

import colors from 'colors'
console.log("Generating Fake Data:".red)

but my console output remains to be:

I20160812-19:55:00.427(-4)? Generating Fake Data:

That first part “I20160812-19:55:00.427(-4)?” is blue, while “Generating Fake Data:” is just gray.

Screenshot:
console.log() screenshot

So, does anyone know another way I can display colors in my server-side console.log()s in Meteor?


I asked this question on StackOverflow a long long time ago and thought to ask it here maybe.

Hi,

I stumbled across your question as I was doing my google-foo. I don’t know if you solved this or not, but here is the solution…

import colors from 'colors';
colors.enabled = true; // This is important
console.log(colors.green('I am green'));

Voilà –

Good luck!

1 Like

Slightly related, but is it possible to customize the timestamp of the logs? The look really weird to me. I can use --raw-logs but then the original colors are gone.