Consolomatic
Console logging with colors, done as simply as it gets.
Consolomatic is an extension of the existing node global Console object to allow coloring of console messages. Unlike other console coloring modules you dont need to write your log/info/war/error calls any differently.
Install
npm install consolomatic
Usage
//import in any file you want colored messages //use like normalconsole;console;console;console;
customise message colors
; //customize the color of console methodsconsole;console; //Use colors inside template strings to color specific words or parts of messagesconsole;
if not using ES6 and module imports
var console = default;var colors = colors;//the rest is the sameconsole;
API
All existing console methods
All of the existing console methods (e.g. .count, .time) work as before. Also, the 'colorised' console methods will still format supplied parameters just like the native methods.
setColor
; //customize the color of console methodsconsole;console;
addConsoleMethod
;console;console;
overrideGlobal
;console;
If you want colored console messages in the entire project but dont want to import consolomatic in every file, you can call overrideGlobal to override the global.console. Due to the way that imports are evaluated (imported module is evaluated before its parent module) you'll need to make this call from an imported 'setup' file see example in examples/example_global_override.js
Colors
text colors
- black
- red
- green
- yellow
- blue
- magenta
- cyan
- white
background colors
- bgBlack
- bgRed
- bgGreen
- bgYellow
- bgBlue
- bgMagenta
- bgCyan
- bgWhite
other styles
support for these varies by platform
- reset
- bright
- dim
- underscore
- blink
- reverse
- hidden