Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

tapc-log

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tapc-log

Logger for tapc

  • 0.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
decreased by-75%
Maintainers
1
Weekly downloads
 
Created
Source

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);
})

Keywords

FAQs

Package last updated on 27 Jul 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc