npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

log-console-color

v1.3.0

Published

控制台自定义标记样式打印(Custom style console printing)

Downloads

1

Readme

English

  • Install

    npm install log-console-color

  • Introduce

    import { ColorConsoleLog , config } from 'log-console-color'

  • Use

    1. Example use
      const log1 = new ColorConsoleLog({ clear: true });
      log1("hello world"); //log1 Prints "hello world" in the default color (red) after clearing all console output.
           
      const log2 = new ColorConsoleLog({ styles: {"color": "blue"}});
      log2("color blue"); //log2 does not clear console output and simply prints "color blue" in the color of blue.
           
      const log3 = new ColorConsoleLog();
      log3("print1","print2","print3"); //log3 prints "print1","print2","print3" using the default configuration options.
    2. Usage of total configuration
      config.switch = false; //All instances are not printed to the console
      config.styles = {
          "color": "blue"
      } //The default console print color is blue for all instances
      config.identify = "==>"; //The default console print delimiter for all instances is '==>'
           
      //... And so on
  • Configuration options

    //The total configuration options are the same as the instance configuration options
    {
      switch: true, //Whether the instance console prints to the console. The default is true
      styles: {
        "color": "red", //The console output color is red by default
        "font-size": "12px", //The default console text size is 12px
          //... Other custom styles
      },
      type: true, //Select whether the first output is a type or a value, the default is true, and the output is a type
      identify: "---> ", //Sets the delimiter, default '---> '
      startNumber: num, //Set the count; the default is false. Start at 1 and add up each time
      msg: false, //When msg is set to true, it means that the first output is customized, and the default is false
      clear: false, //When set to true, it will automatically clear all console output records before printing the current record
    }
  • Description of total configuration option permissions and instance option configuration permissions

    Just two points:

    1. The default option configuration for all instances inherits the total configuration options.
    2. The option configuration permissions of all instances are higher than the total configuration option permissions.

    An example:

    config.switch = false; //All instances are not printed to the console (e.g., production)
      
    const log1 = new ColorConsoleLog();
    log1("hello world"); //log1 does not print "hello world"
      
    const log2 = new ColorConsoleLog();
    log2("color blue"); //log2 does not print "color blue"
      
    const log3 = new ColorConsoleLog({ switch: true });
    log3("print1","print2","print3"); //log3 prints "print1","print2","print3"(e.g., log3 prints in production).

中文

  • 安装

    npm install log-console-color

  • 引入

    import { ColorConsoleLog , config } from 'log-console-color'

  • 使用

    1. 实例使用
      const log1 = new ColorConsoleLog({ clear: true });
      log1("hello world"); //log1清除控制台所有输出记录后打印默认颜色(红色)的“hello world”
           
      const log2 = new ColorConsoleLog({ styles: {"color": "blue"}});
      log2("color blue"); //log2不会清除控制台的输出记录,直接打印蓝色颜色的“color blue”
           
      const log3 = new ColorConsoleLog();
      log3("print1","print2","print3"); //log3使用默认配置选项分别打印输出"print1","print2","print3"
    2. 总配置的使用
      config.switch = false; //所有实例不会在控制台中打印输出
      config.styles = {
          "color": "blue"
      } //所有实例控制台默认打印输出颜色是蓝色
      config.identify = "==>"; //所有实例控制台默认打印输出分隔符是'==>'
           
      //... 等等
  • 配置选项

    //总配置选项和实例配置选项相同
    {
      switch: true, //实例控制台是否打印输出,默认true,打印输出到控制台
      styles: {
        "color": "red", //控制台输出颜色默认为红色
        "font-size": "12px", //控制台文字大小默认为12px
          //... 其他自定义样式
      },
      type: true, //选择打印首输出是类型或者是值,默认true,输出是类型
      identify: "---> ", //设置分隔符,默认是'---> '
      startNumber: num, //设置次数,默认false从1开始,每次累计加一
      msg: false, //设置msg为true时表示打印首输出提示自定义,默认false
      clear: false, //设置为true时自动清除控制台所有输出记录,然后再输出本次记录,默认false
    }
  • 总配置选项权限和实例选项配置权限说明

    就两个点:

    1. 所有实例的默认选项配置继承总配置选项;
    2. 所有实例的选项配置权限是高于总配置选项权限的;

    举例说明:

    config.switch = false; //所有实例不会在控制台中打印输出(比如生产环境)
      
    const log1 = new ColorConsoleLog();
    log1("hello world"); //log1不会打印“hello world”
      
    const log2 = new ColorConsoleLog();
    log2("color blue"); //log2不会打印“color blue”
      
    const log3 = new ColorConsoleLog({ switch: true });
    log3("print1","print2","print3"); //log3会打印print1","print2","print3"(比如生产环境需要log3打印)