@umijs/utils 4.0.0-rc.15 → 4.0.0-rc.18
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/logger.d.ts +3 -0
- package/dist/logger.js +45 -1
- package/package.json +4 -3
package/dist/logger.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export declare const prefixes: {
|
|
2
2
|
wait: string;
|
|
3
3
|
error: string;
|
|
4
|
+
fatal: string;
|
|
4
5
|
warn: string;
|
|
5
6
|
ready: string;
|
|
6
7
|
info: string;
|
|
@@ -14,3 +15,5 @@ export declare function ready(...message: any[]): void;
|
|
|
14
15
|
export declare function info(...message: any[]): void;
|
|
15
16
|
export declare function event(...message: any[]): void;
|
|
16
17
|
export declare function debug(...message: any[]): void;
|
|
18
|
+
export declare function fatal(...message: any[]): void;
|
|
19
|
+
export declare function getLatestLogFilePath(): string;
|
package/dist/logger.js
CHANGED
|
@@ -3,11 +3,39 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.debug = exports.event = exports.info = exports.ready = exports.warn = exports.error = exports.wait = exports.prefixes = void 0;
|
|
6
|
+
exports.getLatestLogFilePath = exports.fatal = exports.debug = exports.event = exports.info = exports.ready = exports.warn = exports.error = exports.wait = exports.prefixes = void 0;
|
|
7
|
+
const path_1 = require("path");
|
|
8
|
+
const pino_1 = __importDefault(require("pino"));
|
|
7
9
|
const chalk_1 = __importDefault(require("../compiled/chalk"));
|
|
10
|
+
const fs_extra_1 = __importDefault(require("../compiled/fs-extra"));
|
|
11
|
+
const loggerDir = (0, path_1.join)(process.cwd(), 'node_modules/.cache/logger');
|
|
12
|
+
const loggerPath = (0, path_1.join)(loggerDir, 'umi.log');
|
|
13
|
+
fs_extra_1.default.mkdirpSync(loggerDir);
|
|
14
|
+
const customLevels = {
|
|
15
|
+
ready: 31,
|
|
16
|
+
event: 32,
|
|
17
|
+
wait: 55,
|
|
18
|
+
// 虽然这里设置了 debug 为 30,但日志中还是 20,符合预期
|
|
19
|
+
// 这里不加会不生成到 umi.log,transport 的 level 配置没有生效,原因不明
|
|
20
|
+
debug: 30,
|
|
21
|
+
};
|
|
22
|
+
const logger = (0, pino_1.default)({
|
|
23
|
+
customLevels,
|
|
24
|
+
}, pino_1.default.transport({
|
|
25
|
+
targets: [
|
|
26
|
+
{
|
|
27
|
+
target: require.resolve('pino/file'),
|
|
28
|
+
options: {
|
|
29
|
+
destination: loggerPath,
|
|
30
|
+
},
|
|
31
|
+
level: 'trace',
|
|
32
|
+
},
|
|
33
|
+
],
|
|
34
|
+
}));
|
|
8
35
|
exports.prefixes = {
|
|
9
36
|
wait: chalk_1.default.cyan('wait') + ' -',
|
|
10
37
|
error: chalk_1.default.red('error') + ' -',
|
|
38
|
+
fatal: chalk_1.default.red('fatal') + ' -',
|
|
11
39
|
warn: chalk_1.default.yellow('warn') + ' -',
|
|
12
40
|
ready: chalk_1.default.green('ready') + ' -',
|
|
13
41
|
info: chalk_1.default.cyan('info') + ' -',
|
|
@@ -16,31 +44,47 @@ exports.prefixes = {
|
|
|
16
44
|
};
|
|
17
45
|
function wait(...message) {
|
|
18
46
|
console.log(exports.prefixes.wait, ...message);
|
|
47
|
+
logger.wait(message[0]);
|
|
19
48
|
}
|
|
20
49
|
exports.wait = wait;
|
|
21
50
|
function error(...message) {
|
|
22
51
|
console.error(exports.prefixes.error, ...message);
|
|
52
|
+
logger.error(message[0]);
|
|
23
53
|
}
|
|
24
54
|
exports.error = error;
|
|
25
55
|
function warn(...message) {
|
|
26
56
|
console.warn(exports.prefixes.warn, ...message);
|
|
57
|
+
logger.warn(message[0]);
|
|
27
58
|
}
|
|
28
59
|
exports.warn = warn;
|
|
29
60
|
function ready(...message) {
|
|
30
61
|
console.log(exports.prefixes.ready, ...message);
|
|
62
|
+
logger.ready(message[0]);
|
|
31
63
|
}
|
|
32
64
|
exports.ready = ready;
|
|
33
65
|
function info(...message) {
|
|
34
66
|
console.log(exports.prefixes.info, ...message);
|
|
67
|
+
logger.info(message[0]);
|
|
35
68
|
}
|
|
36
69
|
exports.info = info;
|
|
37
70
|
function event(...message) {
|
|
38
71
|
console.log(exports.prefixes.event, ...message);
|
|
72
|
+
logger.event(message[0]);
|
|
39
73
|
}
|
|
40
74
|
exports.event = event;
|
|
41
75
|
function debug(...message) {
|
|
42
76
|
if (process.env.DEBUG) {
|
|
43
77
|
console.log(exports.prefixes.debug, ...message);
|
|
44
78
|
}
|
|
79
|
+
logger.debug(message[0]);
|
|
45
80
|
}
|
|
46
81
|
exports.debug = debug;
|
|
82
|
+
function fatal(...message) {
|
|
83
|
+
console.error(exports.prefixes.fatal, ...message);
|
|
84
|
+
logger.fatal(message[0]);
|
|
85
|
+
}
|
|
86
|
+
exports.fatal = fatal;
|
|
87
|
+
function getLatestLogFilePath() {
|
|
88
|
+
return loggerPath;
|
|
89
|
+
}
|
|
90
|
+
exports.getLatestLogFilePath = getLatestLogFilePath;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umijs/utils",
|
|
3
|
-
"version": "4.0.0-rc.
|
|
3
|
+
"version": "4.0.0-rc.18",
|
|
4
4
|
"homepage": "https://github.com/umijs/umi-next/tree/master/packages/utils#readme",
|
|
5
5
|
"bugs": "https://github.com/umijs/umi-next/issues",
|
|
6
6
|
"repository": {
|
|
@@ -21,7 +21,8 @@
|
|
|
21
21
|
"test": "umi-scripts jest-turbo"
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"chokidar": "3.5.3"
|
|
24
|
+
"chokidar": "3.5.3",
|
|
25
|
+
"pino": "7.10.0"
|
|
25
26
|
},
|
|
26
27
|
"devDependencies": {
|
|
27
28
|
"@types/color": "3.0.3",
|
|
@@ -33,7 +34,7 @@
|
|
|
33
34
|
"@types/rimraf": "3.0.2",
|
|
34
35
|
"@types/semver": "7.3.9",
|
|
35
36
|
"address": "1.1.2",
|
|
36
|
-
"axios": "0.
|
|
37
|
+
"axios": "0.27.2",
|
|
37
38
|
"chalk": "5.0.1",
|
|
38
39
|
"cheerio": "1.0.0-rc.10",
|
|
39
40
|
"color": "4.2.3",
|