Files
Checkmate/Client/src/Utils/Logger.js
T

30 lines
613 B
JavaScript
Raw Normal View History

const LOG_LEVEL = import.meta.env.VITE_APP_LOG_LEVEL;
class Logger {
constructor(logLevel) {
const NO_OP = () => {};
2024-08-19 14:28:18 -07:00
if (logLevel === "none") {
this.error = NO_OP;
this.warn = NO_OP;
this.log = NO_OP;
return;
}
this.error = console.error.bind(console);
if (logLevel === "error") {
this.warn = NO_OP;
this.log = NO_OP;
return;
}
this.warn = console.warn.bind(console);
if (logLevel === "warn") {
this.log = NO_OP;
2024-08-19 14:28:18 -07:00
return;
}
this.log = console.log.bind(console);
}
}
export const logger = new Logger(LOG_LEVEL);