LoginSignup
14
14

More than 5 years have passed since last update.

debug パッケージの使い方

Last updated at Posted at 2014-04-11

メモ。

前提として

$ npm install debug --save

ソース

var debug = require('debug')('bar');
var debug2 = require('debug')('hoge');

console.log('foo');
debug('bar');
console.log('baz');
debug2('hoge');

実行の仕方と結果

通常

$ node example.js
foo
baz

DEBUG変数を指定して実行

$ DEBUG=bar node example.js
foo
  bar bar +0ms
baz

$ DEBUG=hoge node example.js
foo
baz
  hoge hoge +0ms

DEBUGを複数指定

$ DEBUG=bar,hoge node example.js
foo
  bar bar +0ms
baz
  hoge hoge +0ms

npmjs.org

debug

14
14
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
14
14