/** * 日志模块 */ export declare module tsLog { /** * 日志级别 */ enum Level { None = 0, Error = 1, Warn = 2, Info = 3, Debug = 4, Trace = 5 } /** * 日志记录器设置 */ type InitOptions = { /** * 输出级别 */ level: Level; /** * 上报级别 */ reportLevel: Level; /** * 关键字 */ tag: string; /** * 补充关键字 */ addTag: string; /** * 日期关键字,默认: false */ dateTag: boolean; /** * 重写日志输出方法,默认:console.log * @param message * @returns */ substitute: (message: string) => void; /** * 设置上报方法,默认: null * @param message * @returns */ reportCaller: (message: string) => void; /** * 是否显示耗时调试信息(默认false) */ isShowDebugTimeUse?: boolean; }; enum ExecTimeLevel { Warn = 20, Error = 50 } /** * 日志记录器 */ class Logger { private static levelTags; private static options; /** * 设置日志记录器 * @param options InitOptions */ static setOptions(options: InitOptions): void; /** * 追加关键字内容 * @param content */ static appendTag(append: string): void; /** * 设置补充关键字 * @param content */ static setAddTag(content: string): void; private static checkLevel; private static toString; /** * 优化日志上传过滤器 */ private static reportFilter; private static report; private static log; private static logf; /** * Level.Trace级别输出,与console.log同样用法 * @param message * @param optionalParams */ static trace(message: any, ...optionalParams: any[]): void; /** * Level.Debug级别输出,与console.log同样用法 * @param message * @param optionalParams */ static debug(message: any, ...optionalParams: any[]): void; /** * Level.Info级别输出,与console.log同样用法 * @param message * @param optionalParams */ static info(message: any, ...optionalParams: any[]): void; /** * Level.Warn级别输出,与console.log同样用法 * @param message * @param optionalParams */ static warn(message: any, ...optionalParams: any[]): void; /** * Level.Error级别输出,与console.log同样用法 * @param message * @param optionalParams */ static error(message: any, ...optionalParams: any[]): void; /** * Level.Trace级别格式化输出 ("example: hello, world 2023") * @param message 带格式的字符串("example: {0}, {1} {2}") * @param optionalParams 任意类型参数(["hello", "world", 2023]) */ static tracef(message: string, ...optionalParams: any[]): void; /** * Level.Debug级别格式化输出 ("example: hello, world 2023") * @param message 带格式的字符串("example: {0}, {1} {2}") * @param optionalParams 任意类型参数(["hello", "world", 2023]) */ static debugf(message: string, ...optionalParams: any[]): void; /** * Level.Info级别格式化输出 ("example: hello, world 2023") * @param message 带格式的字符串("example: {0}, {1} {2}") * @param optionalParams 任意类型参数(["hello", "world", 2023]) */ static infof(message: string, ...optionalParams: any[]): void; /** * Level.Warn级别格式化输出 ("example: hello, world 2023") * @param message 带格式的字符串("example: {0}, {1} {2}") * @param optionalParams 任意类型参数(["hello", "world", 2023]) */ static warnf(message: string, ...optionalParams: any[]): void; /** * Level.Error级别格式化输出 ("example: hello, world 2023") * @param message 带格式的字符串("example: {0}, {1} {2}") * @param optionalParams 任意类型参数(["hello", "world", 2023]) */ static errorf(message: string, ...optionalParams: any[]): void; /** * Level.Trace级别带堆栈输出,与console.log同样用法 * @param message * @param optionalParams */ static traceStack(message: any, ...optionalParams: any[]): void; /** * Level.Debug级别带堆栈输出,与console.log同样用法 * @param message * @param optionalParams */ static debugStack(message: any, ...optionalParams: any[]): void; /** * Level.Info级别带堆栈输出,与console.log同样用法 * @param message * @param optionalParams */ static infoStack(message: any, ...optionalParams: any[]): void; /** * Level.Warn级别带堆栈输出,与console.log同样用法 * @param message * @param optionalParams */ static warnStack(message: any, ...optionalParams: any[]): void; /** * Level.Error级别带堆栈输出,与console.log同样用法 * @param message * @param optionalParams */ static errorStack(message: any, ...optionalParams: any[]): void; /** * Level.Trace级别还堆栈格式化输出 ("example: hello, world 2023" + "\n" + ${stack info}) * @param message 带格式的字符串("example: {0}, {1} {2}") * @param optionalParams 任意类型参数(["hello", "world", 2023]) */ static traceStackf(message: string, ...optionalParams: any[]): void; /** * Level.Debug级别还堆栈格式化输出 ("example: hello, world 2023" + "\n" + ${stack info}) * @param message 带格式的字符串("example: {0}, {1} {2}") * @param optionalParams 任意类型参数(["hello", "world", 2023]) */ static debugStackf(message: string, ...optionalParams: any[]): void; /** * Level.Info级别还堆栈格式化输出 ("example: hello, world 2023" + "\n" + ${stack info}) * @param message 带格式的字符串("example: {0}, {1} {2}") * @param optionalParams 任意类型参数(["hello", "world", 2023]) */ static infoStackf(message: string, ...optionalParams: any[]): void; /** * Level.Warn级别还堆栈格式化输出 ("example: hello, world 2023" + "\n" + ${stack info}) * @param message 带格式的字符串("example: {0}, {1} {2}") * @param optionalParams 任意类型参数(["hello", "world", 2023]) */ static warnStackf(message: string, ...optionalParams: any[]): void; /** * Level.Error级别还堆栈格式化输出 ("example: hello, world 2023" + "\n" + ${stack info}) * @param message 带格式的字符串("example: {0}, {1} {2}") * @param optionalParams 任意类型参数(["hello", "world", 2023]) */ static errorStackf(message: string, ...optionalParams: any[]): void; private static timeUseMap; /** * debug耗时 * @param from 来源关键字 * @param optionalParams 可变参数 */ static debugTimeUse(from: string, ...optionalParams: any[]): void; /** * debug耗时 * @param format 格式化字符串 * @param optionalParams 格式化参数 */ static debugTimeUsef(format: string, ...optionalParams: any[]): void; } }