ts-logger-tools
Version:
`ts-logger-tools` 是一个基于 TypeScript 的日志工具包,旨在为 Node.js 应用程序提供强大的日志记录和管理功能。它支持多种日志类型,包括访问日志、应用日志,并且可以与 MongoDB 集成,用于日志的存储和查询。
39 lines (38 loc) • 895 B
TypeScript
type SortOrder = "asc" | "desc";
export interface Sort {
[field: string]: SortOrder;
}
export interface Log {
traceId: string;
timestamp: number;
level: string;
message: string;
logType: "entry" | "exit";
[key: string]: any;
}
export interface AccessLog extends Log {
requestTime: number;
ipAddress: string;
requestUrl: string;
httpMethod: string;
statusCode: number;
userAgent: string;
responseTime: number;
userId?: string;
string?: string;
}
export interface ApplicationLog extends Log {
action: string;
userId?: string;
details: any;
eventType: "login" | "security" | "trace" | "operation";
loginResult?: "success" | "failure";
failureReason?: string;
spanId?: string;
parentSpanId?: string;
service?: string;
operation?: string;
duration?: number;
error?: boolean;
}
export {};