Files
foka-ci/apps/server/libs/logger.ts
hurole ef473d6084 feat: 完善项目架构和功能
- 修复路由配置,实现根路径自动重定向到/project
- 新增Gitea OAuth认证系统和相关组件
- 完善日志系统实现,包含pino日志工具和中间件
- 重构页面结构,分离项目管理和环境管理页面
- 新增CORS、Session等关键中间件
- 优化前端请求封装和类型定义
- 修复TypeScript类型错误和参数传递问题
2025-09-04 23:19:52 +08:00

39 lines
891 B
TypeScript

import pino from 'pino';
class Logger {
private readonly logger: pino.Logger;
constructor() {
this.logger = pino({
transport: {
target: 'pino-pretty',
options: {
singleLine: true,
colorize: true,
translateTime: 'SYS:standard',
ignore: 'pid,hostname',
},
},
level: 'debug',
});
}
debug(tag: string, message: string, ...args: unknown[]) {
if (args.length > 0) {
this.logger.debug({ TAG: tag }, message, ...(args as []));
} else {
this.logger.debug({ TAG: tag }, message);
}
}
info(tag: string, message: string, ...args: unknown[]) {
this.logger.info({ TAG: tag }, message, ...(args as []));
}
error(tag: string, message: string, ...args: unknown[]) {
this.logger.error({ TAG: tag }, message, ...(args as []));
}
}
export const log = new Logger();