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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@chewbank/consoln

v1.0.3

Published

简洁、优雅、可扩展的console控制台

Downloads

9

Readme

consoln

轻量、简洁、可扩展的console控制台

特性

  • 通过扩展机制实现控制台定制、日志存储、消息订阅等功能

  • 无扩展时可作为美化版的console使用

  • 支持console作用域,可视为轻量版的debug模块

  • 没有日志等级概念,使配置更加灵活,缺点是配置相对繁琐

  • 日志定期存盘,间隔3s存盘

  • 日志拆分,文件按天保存到logger目录下

  • 显示格式化的彩色文本、图标日志

  • 支持扩展自定义日志类型

Install

npm install consoln

示例

// 基础示例

const consoln = require('consoln');

consoln.log('hellow')

consoln.success('hellow success')

consoln.warn({ a: "warn" })

consoln.error(new Error('xx'))

consoln.success('888')
// 扩展日志存档

const consoln = require('consoln');
const logger = require('@consoln/logger');

consoln.show(false); // 不显示log

consoln.use(logger({ "interval": 5000 })); // 添加日志存档,并设定存储间隔为5s

consoln.warn({ a: "warn" })

consoln.error(new Error('xx'))

consoln

使用方法与console类似

consoln.use(options)

consoln的自定义扩展函数,options中的同名属性会被覆盖

  • options Object 自定义配置选项

    • $type Object 类型配置选项,$type对应类型名称

      • $method Function 调用consoln.$type()方法时执行
参考默认配置
consoln.use({
   "log": {
      show(argv) {
         console.log(`\x1b[34m●\x1b[39m`, ...argv);
      }
   },
   "success": {
      show(argv) {
         console.log(`\x1b[32m√\x1b[39m`, ...argv);
      }
   },
   "info": {
      show(argv) {
         console.log(`\x1b[36mi\x1b[39m`, ...argv);
      }
   },
   "warn": {
      show(argv) {
         console.log(`\x1b[33m⚠\x1b[39m`, ...argv);
      }
   },
   "error": {
      show(argv) {
         console.log(`\x1b[31m✖\x1b[39m`, ...argv);
      }
   },
})

consoln.show(false)

关闭控制台log显示功能,提升性能

consoln.log()

consoln.success()

consoln.warn()

consoln.error()

consoln.info()

作用域

日志作用域的使用方法与debug模块类似,区别如下:

  • debug默认不显示log,consoln默认显示log,通过consoln.production()切换到生产环境后关闭日志。

  • debug使用“debug”作为环境变量名,consoln使用“consoln”作为环境变量名。

  • debug的环境变量值支持模糊匹配,consoln不支持模糊匹配,但支持精确匹配多个作用域。

const consoln = require('consoln');
const debug = consoln.scope('debug');
const user = consoln.scope('user');

debug.log('hellow debug');

debug.success('hellow debug');

user.log('hellow user');

user.success('hellow user');