const logContextMap = { DiscordClient: { log: true, warn: true, error: true, }, ServerMain: { log: true, warn: true, error: true, }, API: { log: true, warn: true, error: true, } }; export function logger(sink, context) { let sinkFunction; switch (sink) { case "log": { sinkFunction = console.log; break; } case "warn": { sinkFunction = console.warn; break; } case "error": { sinkFunction = console.error; break; } default: { sinkFunction = () => {}; break; } } if (logContextMap[context] && logContextMap[context][sink]) { return (...e) => { sinkFunction(`[${context}]`, ...e); }; } else { return (...e) => {}; } }