code cleanup/hardening

This commit is contained in:
Storme-bit
2026-04-26 21:53:33 -07:00
parent 43fa12899c
commit 4f3b18de08
7 changed files with 30 additions and 13 deletions

View File

@@ -0,0 +1,12 @@
const LEVELS = { error: 0, warn: 1, info: 2, debug: 3 };
const current = LEVELS[process.env.LOG_LEVEL?.toLowerCase()] ?? LEVELS.info;
const logger = {
error: (...args) => current >= LEVELS.error && console.error('[ERROR]', ...args),
warn: (...args) => current >= LEVELS.warn && console.warn( '[WARN]', ...args),
info: (...args) => current >= LEVELS.info && console.log( '[INFO]', ...args),
debug: (...args) => current >= LEVELS.debug && console.log( '[DEBUG]', ...args),
};
module.exports = logger;