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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@cclr/logger

v0.1.59

Published

轻量日志工具,支持分级输出、全局级别同步与日志监听

Readme

logger

轻量日志工具,支持分级输出、全局级别同步与日志监听。

Usage

npm i @cclr/logger
import { logger } from '@cclr/logger';

logger('默认 info 输出');
logger.debug('调试信息');
logger.info('普通信息');
logger.warn('警告信息');
logger.error('错误信息');

// 设置日志级别:0 debug / 10 info / 20 warn / 30 error
logger.setLevel(0);

// 监听日志输出
const off = logger.onLog((level, ...args) => {
  console.log('收到日志', level, args);
});
off(); // 取消监听

日志级别

| 值 | 级别 | 说明 | |----|------|------| | 0 | debug | 输出全部级别 | | 10 | info | 默认级别,不输出 debug | | 20 | warn | 仅 warn / error | | 30 | error | 仅 error |

级别可通过 logger.LEVEL_MAP 查看名称映射。

多版本互通

同一 JS 运行时内,若存在多份 @cclr/logger 副本,会通过 globalThis.$$__loggerLevel__ 共享日志级别:

// 任意一份 logger 设置级别
logger.setLevel(0);

// 其他副本读取到的也是 debug 级别

兼容 globalThis / window / self,Node 环境降级为模块内缓存。

API 说明

  • logger(...args):默认以 info 级别输出。
  • logger.debug(...args):debug 级别输出。
  • logger.info(...args):info 级别输出。
  • logger.warn(...args):warn 级别输出。
  • logger.error(...args):error 级别输出。
  • logger.setLevel(level):设置日志级别,非法值会被忽略。
  • logger.onLog(callback):监听日志,返回取消监听函数。
  • logger.LEVEL_MAP:级别数值与名称映射。