Skip to content

Commit c5e6b11

Browse files
committed
Make error,notice default debug levels
1 parent ebefa8a commit c5e6b11

File tree

1 file changed

+6
-17
lines changed

1 file changed

+6
-17
lines changed

registry/lib/debug.js

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@ function getDebugJsInstance(namespace) {
2727
if (
2828
!ENV.DEBUG &&
2929
ENV.SOCKET_CLI_DEBUG &&
30-
// Ignore 'inspect' namespace by default.
31-
namespace !== 'inspect'
30+
(namespace === 'error' || namespace === 'notice')
3231
) {
3332
debugJs.enable(namespace)
3433
}
@@ -61,13 +60,11 @@ function customLog() {
6160

6261
/*@__NO_SIDE_EFFECTS__*/
6362
function isEnabled(namespaces) {
64-
if (namespaces === '*') {
63+
if (typeof namespaces !== 'string' || !namespaces || namespaces === '*') {
6564
return true
6665
}
67-
if (typeof namespaces !== 'string' || !namespaces) {
68-
namespaces = 'notice,error'
69-
}
70-
const ENV = /*@__PURE__*/ require('./constants/env')
66+
// Namespace splitting logic is based the 'debug' package implementation:
67+
// https://github.com/debug-js/debug/blob/4.4.1/src/common.js#L169-L173.
7168
const split = namespaces
7269
.trim()
7370
.replace(/\s+/g, ',')
@@ -82,16 +79,8 @@ function isEnabled(namespaces) {
8279
names.push(ns)
8380
}
8481
}
85-
if (names.length) {
86-
const someEnabled = names.some(ns => {
87-
if (!ENV.DEBUG && (ns === 'error' || ns === 'notice')) {
88-
return true
89-
}
90-
return !!getDebugJsInstance(ns).enabled
91-
})
92-
if (!someEnabled) {
93-
return false
94-
}
82+
if (names.length && !names.some(ns => getDebugJsInstance(ns).enabled)) {
83+
return false
9584
}
9685
return skips.every(ns => !getDebugJsInstance(ns).enabled)
9786
}

0 commit comments

Comments
 (0)