@naturalcycles/js-lib 14.245.0 → 14.245.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/log/commonLogger.js
CHANGED
|
@@ -5,7 +5,8 @@ exports.commonLoggerMinLevel = commonLoggerMinLevel;
|
|
|
5
5
|
exports.commonLoggerPipe = commonLoggerPipe;
|
|
6
6
|
exports.commonLoggerPrefix = commonLoggerPrefix;
|
|
7
7
|
exports.commonLoggerCreate = commonLoggerCreate;
|
|
8
|
-
|
|
8
|
+
// copy-pasted to avoid weird circular dependency
|
|
9
|
+
const _noop = (..._args) => undefined;
|
|
9
10
|
exports.commonLogLevelNumber = {
|
|
10
11
|
log: 10,
|
|
11
12
|
warn: 20,
|
|
@@ -17,9 +18,9 @@ exports.commonLogLevelNumber = {
|
|
|
17
18
|
* @experimental
|
|
18
19
|
*/
|
|
19
20
|
exports.commonLoggerNoop = {
|
|
20
|
-
log:
|
|
21
|
-
warn:
|
|
22
|
-
error:
|
|
21
|
+
log: _noop,
|
|
22
|
+
warn: _noop,
|
|
23
|
+
error: _noop,
|
|
23
24
|
};
|
|
24
25
|
/**
|
|
25
26
|
* Creates a "child" logger that is "limited" to the specified CommonLogLevel.
|
|
@@ -28,11 +29,11 @@ function commonLoggerMinLevel(logger, minLevel, mutate = false) {
|
|
|
28
29
|
const level = exports.commonLogLevelNumber[minLevel];
|
|
29
30
|
if (mutate) {
|
|
30
31
|
if (level > exports.commonLogLevelNumber['log']) {
|
|
31
|
-
logger.log =
|
|
32
|
+
logger.log = _noop;
|
|
32
33
|
if (level > exports.commonLogLevelNumber['warn']) {
|
|
33
|
-
logger.warn =
|
|
34
|
+
logger.warn = _noop;
|
|
34
35
|
if (level > exports.commonLogLevelNumber['error']) {
|
|
35
|
-
logger.error =
|
|
36
|
+
logger.error = _noop;
|
|
36
37
|
}
|
|
37
38
|
}
|
|
38
39
|
}
|
|
@@ -47,8 +48,8 @@ function commonLoggerMinLevel(logger, minLevel, mutate = false) {
|
|
|
47
48
|
return exports.commonLoggerNoop;
|
|
48
49
|
}
|
|
49
50
|
return {
|
|
50
|
-
log:
|
|
51
|
-
warn: level <= exports.commonLogLevelNumber['warn'] ? logger.warn.bind(logger) :
|
|
51
|
+
log: _noop, // otherwise it is "log everything" logger (same logger as input)
|
|
52
|
+
warn: level <= exports.commonLogLevelNumber['warn'] ? logger.warn.bind(logger) : _noop,
|
|
52
53
|
error: logger.error.bind(logger), // otherwise it's "log nothing" logger (same as noopLogger)
|
|
53
54
|
};
|
|
54
55
|
}
|
package/package.json
CHANGED
package/src/log/commonLogger.ts
CHANGED