code cleanup/hardening
This commit is contained in:
12
packages/shared/src/utils/logger.js
Normal file
12
packages/shared/src/utils/logger.js
Normal 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;
|
||||
Reference in New Issue
Block a user