console-prettify

1.0.1 • Public • Published

扩展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    

Readme

Keywords

none

Package Sidebar

Install

npm i console-prettify

Weekly Downloads

0

Version

1.0.1

License

ISC

Last publish

Collaborators

  • wheasy