记录器类型
🌐 Logger type
一个记录器工厂函数,它接收一个调试通道前缀,并返回一个用于该通道发出日志的 LoggerFunction,如果该通道的日志被禁用,则返回 undefined。
🌐 A logger factory function that receives a debug channel prefix and returns a LoggerFunction to emit logs for that channel, or undefined if logging is disabled for that channel.
语法
🌐 Signature
export type Logger = (prefix: string) => LoggerFunction | undefined;
参考资料: LoggerFunction
示例
🌐 Example
const customLogger: Logger = (prefix: string) => {
if (prefix.includes('protocol')) {
return (...args: unknown[]) => console.log(`[DEBUG: ${prefix}]`, ...args);
}
return undefined;
};