@agentkai/core
Version:
AgentKai核心包,提供AI助手系统的基础功能
117 lines • 2.82 kB
TypeScript
/**
* 日志级别枚举
*/
export declare enum LogLevel {
DEBUG = 0,
INFO = 1,
WARN = 2,
ERROR = 3,
SILENT = 4
}
/**
* 控制台颜色代码,用于美化输出
*/
export declare const Colors: {
reset: string;
bright: string;
dim: string;
underscore: string;
black: string;
red: string;
green: string;
yellow: string;
blue: string;
magenta: string;
cyan: string;
white: string;
gray: string;
success: string;
error: string;
warn: string;
info: string;
debug: string;
};
/**
* 日志配置选项
*/
export interface LoggerOptions {
/** 是否启用彩色输出 */
enableColors?: boolean;
/** 是否显示时间戳 */
showTimestamp?: boolean;
/** 是否显示日志级别 */
showLogLevel?: boolean;
/** 是否显示模块名称 */
showModule?: boolean;
/** 时间戳格式化函数 */
timestampFormatter?: (date: Date) => string;
/** 自定义格式化整个日志消息 */
messageFormatter?: (level: LogLevel, module: string, message: string, data?: unknown) => string;
}
/**
* 高级日志工具,支持多种输出格式和颜色
*/
export declare class Logger {
private module;
private static globalLogLevel;
private static globalOptions;
private options;
constructor(moduleName: string, options?: LoggerOptions);
/**
* 设置全局日志级别
*/
static setGlobalLogLevel(level: LogLevel | string): void;
/**
* 设置全局日志配置
*/
static setGlobalOptions(options: LoggerOptions): void;
/**
* 获取当前全局日志配置
*/
static getGlobalOptions(): LoggerOptions;
/**
* 获取当前全局日志级别
*/
static getGlobalLogLevel(): LogLevel;
/**
* 获取当前全局日志级别名称
*/
static getGlobalLogLevelName(): string;
/**
* 格式化日志消息
*/
private formatMessage;
/**
* 记录信息级别日志
*/
info(message: string, data?: unknown): void;
/**
* 记录错误级别日志
*/
error(message: string, error?: Error | unknown): void;
/**
* 记录警告级别日志
*/
warn(message: string, data?: unknown): void;
/**
* 记录调试级别日志
*/
debug(message: string, data?: unknown): void;
/**
* 记录带有成功样式的信息
*/
success(message: string, data?: unknown): void;
/**
* 创建一个分组标题,用于标记一组相关日志
*/
group(title: string): void;
/**
* 创建一个简单的分隔线
*/
divider(length?: number): void;
/**
* 创建一个带有标题的分隔线
*/
section(title: string): void;
}
//# sourceMappingURL=logger.d.ts.map