feat: 实现完整的用户管理系统和日志配置优化 #1

Merged
moyin merged 5 commits from feature/user-management-system into main 2025-12-17 11:13:54 +08:00
Showing only changes of commit 8fbfc0202b - Show all commits

View File

@@ -82,7 +82,7 @@ export class LoggerConfigFactory {
},
// 自定义错误响应消息
customErrorMessage: (req: any, res: any, err: any) => {
customErrorMessage: (req: any, _res: any, err: any) => {
return `${req.method} ${req.url} failed: ${err.message}`;
},
},
@@ -152,20 +152,7 @@ export class LoggerConfigFactory {
translateTime: 'SYS:yyyy-mm-dd HH:MM:ss',
ignore: 'pid,hostname',
messageFormat: '{app} [{level}] {msg}',
customPrettifiers: {
time: (timestamp: any) => `🕐 ${timestamp}`,
level: (logLevel: any) => {
const levelEmojis: Record<number, string> = {
10: '🔍', // trace
20: '🐛', // debug
30: '📝', // info
40: '⚠️', // warn
50: '❌', // error
60: '💀', // fatal
};
return `${levelEmojis[logLevel] || '📝'} ${logLevel}`;
},
},
// 移除 customPrettifiers 以避免 Worker 线程序列化问题
},
level: logLevel,
},
@@ -231,13 +218,13 @@ export class LoggerConfigFactory {
/**
* 自定义日志级别判断
*
* @param req HTTP 请求对象
* @param _req HTTP 请求对象
* @param res HTTP 响应对象
* @param err 错误对象
* @returns 日志级别
* @private
*/
private static customLogLevel(req: any, res: any, err: any) {
private static customLogLevel(_req: any, res: any, err: any) {
if (res.statusCode >= 400 && res.statusCode < 500) {
return 'warn';
} else if (res.statusCode >= 500 || err) {
@@ -255,7 +242,7 @@ export class LoggerConfigFactory {
* @private
*/
private static generateRequestId(): string {
return `req_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`;
return `req_${Date.now()}_${Math.random().toString(36).substring(2, 11)}`;
}
/**