Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
private createRtmClient(token: string, logLabel: string): RTMClient {
const LOG_LEVELS = ["debug", "info", "warn", "error", "silent"];
const connLog = Logging.get(`RTM-${logLabel.substr(0, LOG_TEAM_LEN)}`);
const logLevel = LOG_LEVELS.indexOf(this.main.config.rtm!.log_level || "silent");
const rtm = new RTMClient(token, {
logLevel: LogLevel.DEBUG, // We will filter this ourselves.
logger: {
getLevel: () => LogLevel.DEBUG,
setLevel: () => {},
setName: () => {}, // We handle both of these ourselves.
debug: logLevel <= 0 ? connLog.debug.bind(connLog) : () => {},
warn: logLevel <= 1 ? connLog.warn.bind(connLog) : () => {},
info: logLevel <= 2 ? connLog.info.bind(connLog) : () => {},
error: logLevel <= 3 ? connLog.error.bind(connLog) : () => {},
} as Logger,
});
rtm.on("error", (error) => {
// We must handle this lest the process be killed.
connLog.error("Encountered 'error' event:", error);
});
return rtm;
getLevel: () => LogLevel.DEBUG,
setLevel: () => {},