1.0.1 • Published 8 years ago

console-prettify v1.0.1

Weekly downloads
2
License
ISC
Repository
github
Last release
8 years ago

扩展console,增加log、warn、error、info颜色输出。并新增 blue、cyan、green、magenta方法。

安装

npm install console-prettify

使用

require('console-prettify')();

console.log('hello console');

参数

前缀prefix

默认没有前缀,如要输出前缀,传参即可

require('console-prettify')({
    prefix: true
});

console.log('log')
console.info('info')

结果:

log: log info: info error: info

自定义样式theme

如果默认样式满足你的需求,你可以通过theme参数自定义样式。

样式
    require('console-prettify')({
        prefix: true,
        theme:{
            log: ['underline' ,'green', 'redBG']
        }
    });

    console.log('hello log')

输出:

log:hello log

Theme属性列表
名称示例
bold粗体
underline下划线_
inverse反色
strikethrough删除线

有些属性貌似不支持,貌似我的Mac就不支持删除线

文字颜色示例
属性示例
white...
grey...
black...
blue...
cyan   
green   
magenta   
red   
yellow   
背景颜色示例
属性示例
whiteBG...
greyBG...
blackBG...
blueBG   
cyanBG   
greenBG   
magentaBG   
redBG   
yellowBG