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

node-bugjs

v2.0.1

Published

debug for node.js .

Downloads

10

Readme

node-bugjs

node-bugjs 是 node.js 的一个调试工具。

  • 支持5中主题样式(白,红,绿,黄,蓝)
  • 显示当前输出日志代码行号,方便开发调试
  • 支持定义log回调处理,实现log记录功能

注:已经不支持 [email protected] 的用法。

install

npm install -S node-bugjs
const bugjs = require('node-bugjs')('http')

bugjs.log('wellcome')

api

const Bugjs = require('node-bugjs')

const bugjs = new Bugjs(options || 'categorie')
// or
const bugjs = Bugjs(options)
  • Bugjs.prototype.config(options) 配置
  • Bugjs.prototype.log(any, any, ...)
  • Bugjs.prototype.info(any, any, ...)
  • Bugjs.prototype.success(any, any, ...)
  • Bugjs.prototype.error(any, any, ...)
  • Bugjs.prototype.warn(any, any, ...)
  • Bugjs.prototype.storeHandler = (logs) => {} 定义log回调,可以用来实现记录日志
  • Bugjs.Callsites 获取调用栈对象,可以new CallSite()创建

options:

  • options.console 打印到控制台,默认true
  • options.store 是否开启写store回调,默认false
  • options.categorie 标签,默认''
  • options.categorieColor 标签样式,请看支持的 styles
  • options.debug 是否开启debug模式,默认 true (process.env.NODE_ENV !== 'production'),开启后会显示当前调用文件行号
  • options.absolute 显示文件路径是否是绝对路径,默认 false
  • options.bright 是否亮色,默认 false
  • options.date 是否显示时间,默认 false
  • options.dateColor 显示时间样式,默认 'blue',请看支持的 styles
  • options.filenameColor 文件名样式,默认 'gray',请看支持的 styles
  • options.callIndex 指定调用栈序号,共10,默认2

可以运行 demo.js 查看效果

注:显示文件名和行号会影响js性能,上线项目请自行删掉log,或者配置debug为false

记录日志

// 记录到日志
bugjs.storeHandler = function (log) {
  var logs = []
  for (var key in log) {
    if (key !== 'logs') {
      logs.push(log[key])
    }
  }
  logs.push(' ')
  fs.appendFileSync(this.categorie + '.log', logs.concat(log.logs).join('') + '\n')
}

支持样式

black
red
green
yellow
blue
magenta
cyan
white
gray

redBright
greenBright
yellowBright
blueBright
magentaBright
cyanBright
whiteBright

bgBlack
bgRed
bgGreen
bgYellow
bgBlue
bgMagenta
bgCyan
bgWhite

bgBlackBright
bgRedBright
bgGreenBright
bgYellowBright
bgBlueBright
bgMagentaBright
bgCyanBright
bgWhiteBright

效果图

截图1

other

colors V8 stack trace API