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

tapc-log

v0.1.0

Published

Logger for tapc

Downloads

25

Readme

tapc-log

Test coverage Build Status Dependency Status devDependency Status NPM version node License npm download

使用方法:

需要传入当前引用日志模块的(命名空间:作者名),以便在多个模块集成时,区分日志来源。

var log = require('tapc-log')('a:author');
log.start() // 如果需要改写流,才需要调用此方法,tap插件才能使用,gulp插件不要使用该方法
log.warn('aa');

可供调用的log 方法:

  • all: except for the following
  • debug: messages to debug an application
  • info: a purely informational message
  • warn: warning condition
  • error: error condition

example:

log.all('xxxxx')
log.debug('xxxxx')
log.info('xxxxx')
log.warn('xxxxx')
log.error('xxxxx')

ps:log.error 会输出模块的author。

设置debug状态:

log.setDebug(true)

ps:只有在debug模式下,log.all和log.debug的内容才进行输出,log内容会被写入本地(process.env.HOME,'.tap','tap.log')。

第三方插件兼容机制:

只有输出内容中符合

console.log('[info]xxx');
console.log('(info)xxx');
console.log('[warn]xxx');
console.error('(error)xxx');

这类的才能被匹配到对应的日志级别,其他不被捕获的log信息,stdout流的都当做info处理,stderr流的都当做err处理

强制不输出某些内容

log.stdoutPut(false);
不想被输出的内容
log.stdoutPut(true);

关掉以后记得开启,不然后续所有内容都无法输出。

不做任何处理直接输出

log.plain('xxxxx');

Q:spawn依赖log模块的插件,如何获取期望的log输出?

A:当spawn启动一个依赖于log模块的插件,需要指定他的stdio为pipe,如果不指定,无法正确识别作者名。

Q:spawn如果希望用pipe的方式调用,如何避免log头部的重复输出?

A:使用如下方法

var ps = spawn('node', ['./b.js'], {
  cwd:process.cwd(),
  env:process.env,
  stdio:'pipe'
});
ps.stdout.on('data', function(data) {
  log.plain(data);
})