@gadmin2n/schematics 0.0.115 → 0.0.117
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.
|
@@ -17,7 +17,7 @@ import modules from './modules';
|
|
|
17
17
|
import { ScheduleModule } from '@nestjs/schedule';
|
|
18
18
|
import { ServeStaticModule } from '@nestjs/serve-static';
|
|
19
19
|
import { join } from 'path';
|
|
20
|
-
import {
|
|
20
|
+
import { consoleFormat } from './lib/logger';
|
|
21
21
|
import { AgendaModule } from './modules/agenda/agenda.module';
|
|
22
22
|
import { HealthModule } from './modules/health/health.module';
|
|
23
23
|
import { RoleModule } from './modules/role/role.module';
|
|
@@ -54,7 +54,7 @@ import { RolesRefresherService } from './modules/role/roles-refresher.service';
|
|
|
54
54
|
level: loggerConfig.level,
|
|
55
55
|
transports: [
|
|
56
56
|
new winston.transports.Console({
|
|
57
|
-
format:
|
|
57
|
+
format: consoleFormat,
|
|
58
58
|
}),
|
|
59
59
|
],
|
|
60
60
|
};
|
|
@@ -1,19 +1,37 @@
|
|
|
1
1
|
import * as winston from 'winston';
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
const baseFormats = [
|
|
4
4
|
winston.format.splat(),
|
|
5
|
-
winston.format.timestamp({
|
|
6
|
-
format: 'YYYY-MM-DD HH:mm:ss.SSS',
|
|
7
|
-
}),
|
|
5
|
+
winston.format.timestamp({ format: 'YYYY-MM-DD HH:mm:ss.SSS' }),
|
|
8
6
|
winston.format.errors({ stack: true }),
|
|
7
|
+
];
|
|
8
|
+
|
|
9
|
+
// 非终端(文件重定向、容器日志收集等)输出纯 JSON,方便机器解析
|
|
10
|
+
export const LogFormat = winston.format.combine(
|
|
11
|
+
...baseFormats,
|
|
9
12
|
winston.format.json(),
|
|
10
13
|
);
|
|
11
14
|
|
|
15
|
+
// 终端输出:带 ANSI 颜色,方便肉眼阅读
|
|
16
|
+
const ttyFormat = winston.format.combine(
|
|
17
|
+
...baseFormats,
|
|
18
|
+
winston.format.colorize(),
|
|
19
|
+
winston.format.printf(
|
|
20
|
+
({ timestamp, level, message, context, stack, ...rest }) => {
|
|
21
|
+
const ctx = context ? ` [${context}]` : '';
|
|
22
|
+
const extra = Object.keys(rest).length ? ' ' + JSON.stringify(rest) : '';
|
|
23
|
+
return `${timestamp}${ctx} ${level}: ${stack ?? message}${extra}`;
|
|
24
|
+
},
|
|
25
|
+
),
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
export const consoleFormat = process.stdout.isTTY ? ttyFormat : LogFormat;
|
|
29
|
+
|
|
12
30
|
export const loggerInstance = winston.createLogger({
|
|
13
31
|
level: 'info',
|
|
14
32
|
transports: [
|
|
15
33
|
new winston.transports.Console({
|
|
16
|
-
format:
|
|
34
|
+
format: consoleFormat,
|
|
17
35
|
}),
|
|
18
36
|
],
|
|
19
37
|
});
|
|
@@ -14,7 +14,11 @@ i18n
|
|
|
14
14
|
zh_CN: { common: zh_CN },
|
|
15
15
|
},
|
|
16
16
|
defaultNS: 'common',
|
|
17
|
-
fallbackLng:
|
|
17
|
+
fallbackLng: 'zh_CN',
|
|
18
|
+
detection: {
|
|
19
|
+
order: ['querystring', 'cookie', 'localStorage'],
|
|
20
|
+
caches: ['localStorage', 'cookie'],
|
|
21
|
+
},
|
|
18
22
|
react: {
|
|
19
23
|
useSuspense: false,
|
|
20
24
|
},
|