Debug: DEBUG_DEPTH not working

Created on 8 Feb 2020  路  6Comments  路  Source: visionmedia/debug

DEBUG_DEPTH env var has no effect. I tried values of 10, 100, null. No matter what I always get the following display:

2020-02-08T22:17:01.423Z SCOPE STRING [ { email: '[email protected]', vars: [ [Object] ] } ]

My invocation:

debug('STRING', targetObj);
bug

Most helpful comment

I should have noted it reproduces only when deep object is the second argument to the debug function, e.g.

Yeah that's much less simple to fix; there are a few bugs surrounding this. v5 is going to be a rewrite for the most part, so a lot of this will get addressed then.

Glad to know it works now (mostly); I'll commit it in sometime soon. Thank you very much for testing @anishkny :)

All 6 comments

Noticed this also. Looks like it is defaulting to 3 and not allowing an override...

Any fix in the works?

Yep looks like a regression somewhere.

Can you test with npm i --no-save visionmedia/debug#fix/depth?

Started down the git blame rabbit hole. If that branch fixes it, then this has been broken for years. Amazing.

Looks like fix is effective. Any place to add unit tests for this?

I should have noted it reproduces only when deep object is the _second_ argument to the debug function, e.g.

// index.js
require('debug')('FOO')('something', {
  x: 1,
  y: { a: 2, b: 3, c: { a: 1, b: { a: 1, b: { a: 1, b: { a: 1 } } } } },
});

Before fix:

$ DEBUG=FOO DEBUG_DEPTH=40 node index.js
  FOO something { x: 1, y: { a: 2, b: 3, c: { a: 1, b: [Object] } } } +0ms

After fix:

$ DEBUG=FOO DEBUG_DEPTH=40 node index.js
  FOO something {
  x: 1,
  y: {
    a: 2,
    b: 3,
    c: {
      a: 1,
      b: { a: 1, b: { a: 1, b: { a: 1 } } }
    }
  }
} +0ms

I should have noted it reproduces only when deep object is the second argument to the debug function, e.g.

Yeah that's much less simple to fix; there are a few bugs surrounding this. v5 is going to be a rewrite for the most part, so a lot of this will get addressed then.

Glad to know it works now (mostly); I'll commit it in sometime soon. Thank you very much for testing @anishkny :)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

yarmyarch picture yarmyarch  路  7Comments

pavanjadhaw picture pavanjadhaw  路  5Comments

Qix- picture Qix-  路  4Comments

Qix- picture Qix-  路  7Comments

BertCatsburg picture BertCatsburg  路  5Comments