// Leveled logger. Outputs to console with [AutistMask] prefix. // Level is DEBUG when the DEBUG constant is true, INFO otherwise. const { DEBUG } = require("./constants"); const LEVELS = { debug: 0, info: 1, warn: 2, error: 3 }; const threshold = DEBUG ? LEVELS.debug : LEVELS.info; function emit(level, method, args) { if (LEVELS[level] >= threshold) { console[method]("[AutistMask]", ...args); } } const log = { debugf(...args) { emit("debug", "log", args); }, infof(...args) { emit("info", "log", args); }, warnf(...args) { emit("warn", "warn", args); }, errorf(...args) { emit("error", "error", args); }, }; module.exports = { log };