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

fh-csl

v0.0.8

Published

Beautify console logs

Downloads

11

Readme

fh-csl 日志插件文档

fh-csl 用于美化 浏览器 控制台日志输出格式。

  • 支持微信小程序,区分手机与开发者工具。
  • 支持自定义日志颜色

安装

npm i fh-csl -S

快速使用

// 引入插件
import csl from 'fh-csl';

// 打印日志的几种形式
csl.log("app>boot>page");
csl.info("app>boot>page", "页面启动");
csl.debug("app>boot>page", "页面启动", { url: "/index" });
csl.warn("app", "boot", "page", "页面启动", { url: "/index" });
csl.error({
  subject: "app",
  action: "boot",
  target: "page",
  remark: "页面启动",
  extra: { url: "/index" },
});

日志追踪

点开日志左边的小箭头,再打开 stack trace,可以追踪到日志的完整路径。
开发者可以利用这个追踪错误源,解决 bug。

API 列表

.log() 打印 log 日志

csl.log('app>boot>page')
csl.log('app>boot>page', '页面启动')
csl.log('app>boot>page', '页面启动', { url: '/index' })
csl.log('app', 'boot', 'page', '页面启动', { url: '/index' })
csl.log({
  subject: 'app',
  action: 'boot',
  target: 'page',
  remark: '页面启动',
  extra: { url: '/index' }
})

.info() 打印 info 日志

csl.info('app>boot>page')
csl.info('app>boot>page', '页面启动')
csl.info('app>boot>page', '页面启动', { url: '/index' })
csl.info('app', 'boot', 'page', '页面启动', { url: '/index' })
csl.info({
  subject: 'app',
  action: 'boot',
  target: 'page',
  remark: '页面启动',
  extra: { url: '/index' }
})

.debug() 打印 debug 日志

csl.debug('app>boot>page')
csl.debug('app>boot>page', '页面启动')
csl.debug('app>boot>page', '页面启动', { url: '/index' })
csl.debug('app', 'boot', 'page', '页面启动', { url: '/index' })
csl.debug({
  subject: 'app',
  action: 'boot',
  target: 'page',
  remark: '页面启动',
  extra: { url: '/index' }
})

.warn() 打印 warn 日志

csl.warn('app>boot>page')
csl.warn('app>boot>page', '页面启动')
csl.warn('app>boot>page', '页面启动', { url: '/index' })
csl.warn('app', 'boot', 'page', '页面启动', { url: '/index' })
csl.warn({
  subject: 'app',
  action: 'boot',
  target: 'page',
  remark: '页面启动',
  extra: { url: '/index' }
})

.error() 打印 error 日志

csl.error('app>boot>page')
csl.error('app>boot>page', '页面启动')
csl.error('app>boot>page', '页面启动', { url: '/index' })
csl.error('app', 'boot', 'page', '页面启动', { url: '/index' })
csl.error({
  subject: 'app',
  action: 'boot',
  target: 'page',
  remark: '页面启动',
  extra: { url: '/index' }
})

.setGrab() 设置是用覆盖 console 对象

csl.setGrab(true) // 占用 console 对象
csl.setGrab(false) // 释放 console 对象

.setIgnores() 设置忽略规则

// * 代表所有
csl.setIgnores([
  'warn>app>boot>page', 
  'error>app>boot>*',
  'log>app>*>page',
  'info>*>boot>page',
  '*>app>boot>page',
  // ...更多用法可以尝试
])

.clearIgnores() 清除忽略规则

csl.clearIgnores()

.setSubjectColors() 设置主体颜色

cs.setSubjectColors({
  req: '#aaa',
  res: '#00aa00',
  soc: '#ff34b3',
  bus: '##9932cc',
  app: '#7fff00',
  non: '#f00',
  sys: '#666',
})

.setSubjectColors() 设置主体颜色

csl.clearSubjectColors()

.setDefaultSubjectColor() 设置默认主体颜色

csl.setDefaultSubjectColor('purple')