Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

console-prettify

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

console-prettify

readme.md

latest
Source
npmnpm
Version
1.0.1
Version published
Maintainers
1
Created
Source

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

FAQs

Package last updated on 29 Mar 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts