xpl / ololog

A better console.log for the log-driven debugging junkies
https://www.npmjs.com/package/ololog
The Unlicense
215 stars 8 forks source link

background color #3

Closed jjhesk closed 6 years ago

jjhesk commented 6 years ago

is that possible to get a background color for the printed string? how to achieve this effect?

xpl commented 6 years ago

Yeah, try something like log.bgBrightYellow.green ('foo'). You can look up names of the styling functions here: https://github.com/xpl/ansicolor#supported-styles

You can also use your favourite ANSI styling library, like Chalk or ansicolor (ololog uses Ansicolor internally) to color selected parts of the string, like this:

ansi = require ('ansicolor')

log ('foo' + ansi.bgRed ('bar') + 'baz')

or like this (it is not recommented, as it extends the built-in String prototype, but you still may find it useful):

require ('ansicolor').nice

log ('foo' + 'bar'.bgRed + 'baz')
jjhesk commented 6 years ago

thanks for the fast reply, yup. i will try. thanks for the awesome lib

xpl commented 6 years ago

Feel free to ask questions :) I'm closing this issue for now.