@lodestar/logger 1.41.0-dev.bb33751bfd → 1.41.0-dev.be5acbb8f7
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/lib/testUtils.d.ts +14 -0
- package/lib/testUtils.d.ts.map +1 -0
- package/lib/testUtils.js +24 -0
- package/lib/testUtils.js.map +1 -0
- package/package.json +9 -4
- package/src/testUtils.ts +26 -0
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { LogLevel } from "@lodestar/utils";
|
|
2
|
+
import { LoggerNode, LoggerNodeOpts } from "./node.js";
|
|
3
|
+
export { LogLevel };
|
|
4
|
+
export type TestLoggerOpts = LoggerNodeOpts;
|
|
5
|
+
/**
|
|
6
|
+
* Run the test with ENVs to control log level:
|
|
7
|
+
* ```
|
|
8
|
+
* LOG_LEVEL=debug vitest .ts
|
|
9
|
+
* DEBUG=1 vitest .ts
|
|
10
|
+
* VERBOSE=1 vitest .ts
|
|
11
|
+
* ```
|
|
12
|
+
*/
|
|
13
|
+
export declare const testLogger: (module?: string, opts?: TestLoggerOpts) => LoggerNode;
|
|
14
|
+
//# sourceMappingURL=testUtils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"testUtils.d.ts","sourceRoot":"","sources":["../src/testUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAC,MAAM,iBAAiB,CAAC;AAEzC,OAAO,EAAC,UAAU,EAAE,cAAc,EAAgB,MAAM,WAAW,CAAC;AACpE,OAAO,EAAC,QAAQ,EAAC,CAAC;AAElB,MAAM,MAAM,cAAc,GAAG,cAAc,CAAC;AAE5C;;;;;;;GAOG;AACH,eAAO,MAAM,UAAU,GAAI,SAAS,MAAM,EAAE,OAAO,cAAc,KAAG,UAUnE,CAAC"}
|
package/lib/testUtils.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { LogLevel } from "@lodestar/utils";
|
|
2
|
+
import { getEnvLogLevel } from "./env.js";
|
|
3
|
+
import { getNodeLogger } from "./node.js";
|
|
4
|
+
export { LogLevel };
|
|
5
|
+
/**
|
|
6
|
+
* Run the test with ENVs to control log level:
|
|
7
|
+
* ```
|
|
8
|
+
* LOG_LEVEL=debug vitest .ts
|
|
9
|
+
* DEBUG=1 vitest .ts
|
|
10
|
+
* VERBOSE=1 vitest .ts
|
|
11
|
+
* ```
|
|
12
|
+
*/
|
|
13
|
+
export const testLogger = (module, opts) => {
|
|
14
|
+
if (opts == null) {
|
|
15
|
+
opts = {};
|
|
16
|
+
}
|
|
17
|
+
if (module) {
|
|
18
|
+
opts.module = module;
|
|
19
|
+
}
|
|
20
|
+
const level = getEnvLogLevel();
|
|
21
|
+
opts.level = level ?? opts.level ?? LogLevel.info;
|
|
22
|
+
return getNodeLogger(opts);
|
|
23
|
+
};
|
|
24
|
+
//# sourceMappingURL=testUtils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"testUtils.js","sourceRoot":"","sources":["../src/testUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAC,MAAM,iBAAiB,CAAC;AACzC,OAAO,EAAC,cAAc,EAAC,MAAM,UAAU,CAAC;AACxC,OAAO,EAA6B,aAAa,EAAC,MAAM,WAAW,CAAC;AACpE,OAAO,EAAC,QAAQ,EAAC,CAAC;AAIlB;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,MAAe,EAAE,IAAqB,EAAc,EAAE;IAC/E,IAAI,IAAI,IAAI,IAAI,EAAE,CAAC;QACjB,IAAI,GAAG,EAAoB,CAAC;IAC9B,CAAC;IACD,IAAI,MAAM,EAAE,CAAC;QACX,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IACD,MAAM,KAAK,GAAG,cAAc,EAAE,CAAC;IAC/B,IAAI,CAAC,KAAK,GAAG,KAAK,IAAI,IAAI,CAAC,KAAK,IAAI,QAAQ,CAAC,IAAI,CAAC;IAClD,OAAO,aAAa,CAAC,IAAI,CAAC,CAAC;AAC7B,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"bugs": {
|
|
12
12
|
"url": "https://github.com/ChainSafe/lodestar/issues"
|
|
13
13
|
},
|
|
14
|
-
"version": "1.41.0-dev.
|
|
14
|
+
"version": "1.41.0-dev.be5acbb8f7",
|
|
15
15
|
"type": "module",
|
|
16
16
|
"exports": {
|
|
17
17
|
".": {
|
|
@@ -38,6 +38,11 @@
|
|
|
38
38
|
"bun": "./src/empty.ts",
|
|
39
39
|
"types": "./lib/empty.d.ts",
|
|
40
40
|
"import": "./lib/empty.js"
|
|
41
|
+
},
|
|
42
|
+
"./test-utils": {
|
|
43
|
+
"bun": "./src/testUtils.ts",
|
|
44
|
+
"types": "./lib/testUtils.d.ts",
|
|
45
|
+
"import": "./lib/testUtils.js"
|
|
41
46
|
}
|
|
42
47
|
},
|
|
43
48
|
"files": [
|
|
@@ -62,7 +67,7 @@
|
|
|
62
67
|
},
|
|
63
68
|
"types": "lib/index.d.ts",
|
|
64
69
|
"dependencies": {
|
|
65
|
-
"@lodestar/utils": "^1.41.0-dev.
|
|
70
|
+
"@lodestar/utils": "^1.41.0-dev.be5acbb8f7",
|
|
66
71
|
"triple-beam": "^1.3.0",
|
|
67
72
|
"winston": "^3.8.2",
|
|
68
73
|
"winston-daily-rotate-file": "^4.7.1",
|
|
@@ -71,7 +76,7 @@
|
|
|
71
76
|
"devDependencies": {
|
|
72
77
|
"@chainsafe/ssz": "^1.2.2",
|
|
73
78
|
"@chainsafe/threads": "^1.11.3",
|
|
74
|
-
"@lodestar/test-utils": "^1.41.0-dev.
|
|
79
|
+
"@lodestar/test-utils": "^1.41.0-dev.be5acbb8f7",
|
|
75
80
|
"@types/triple-beam": "^1.3.2"
|
|
76
81
|
},
|
|
77
82
|
"keywords": [
|
|
@@ -80,5 +85,5 @@
|
|
|
80
85
|
"beacon",
|
|
81
86
|
"blockchain"
|
|
82
87
|
],
|
|
83
|
-
"gitHead": "
|
|
88
|
+
"gitHead": "daf32e31b38dd272b28016e37de0d0419ce72864"
|
|
84
89
|
}
|
package/src/testUtils.ts
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import {LogLevel} from "@lodestar/utils";
|
|
2
|
+
import {getEnvLogLevel} from "./env.js";
|
|
3
|
+
import {LoggerNode, LoggerNodeOpts, getNodeLogger} from "./node.js";
|
|
4
|
+
export {LogLevel};
|
|
5
|
+
|
|
6
|
+
export type TestLoggerOpts = LoggerNodeOpts;
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Run the test with ENVs to control log level:
|
|
10
|
+
* ```
|
|
11
|
+
* LOG_LEVEL=debug vitest .ts
|
|
12
|
+
* DEBUG=1 vitest .ts
|
|
13
|
+
* VERBOSE=1 vitest .ts
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
export const testLogger = (module?: string, opts?: TestLoggerOpts): LoggerNode => {
|
|
17
|
+
if (opts == null) {
|
|
18
|
+
opts = {} as LoggerNodeOpts;
|
|
19
|
+
}
|
|
20
|
+
if (module) {
|
|
21
|
+
opts.module = module;
|
|
22
|
+
}
|
|
23
|
+
const level = getEnvLogLevel();
|
|
24
|
+
opts.level = level ?? opts.level ?? LogLevel.info;
|
|
25
|
+
return getNodeLogger(opts);
|
|
26
|
+
};
|