ts-logger-tools
Version:
`ts-logger-tools` 是一个基于 TypeScript 的日志工具包,旨在为 Node.js 应用程序提供强大的日志记录和管理功能。它支持多种日志类型,包括访问日志、应用日志,并且可以与 MongoDB 集成,用于日志的存储和查询。
33 lines (32 loc) • 1.09 kB
JavaScript
// src/syncer/index.ts
Object.defineProperty(exports, "__esModule", { value: true });
exports.LogManager = void 0;
class LogManager {
constructor(syncers) {
this.syncers = syncers;
}
async syncLog(log, syncMethod) {
const syncPromises = this.syncers.map((syncer) => syncMethod(syncer, log));
await Promise.all(syncPromises);
}
async logAccess(log) {
await this.syncLog(log, (syncer) => syncer.syncAccessLog(log));
}
async logLogin(log) {
// 这里使用 ApplicationLog 类型
await this.syncLog(log, (syncer) => syncer.syncLoginLog(log));
}
async logApplication(log) {
await this.syncLog(log, (syncer) => syncer.syncApplicationLog(log));
}
async logSecurity(log) {
// 这里使用 ApplicationLog 类型
await this.syncLog(log, (syncer) => syncer.syncSecurityLog(log));
}
async logTrace(log) {
// 这里使用 ApplicationLog 类型
await this.syncLog(log, (syncer) => syncer.syncTraceLog(log));
}
}
exports.LogManager = LogManager;
;