implement basic logger, replace console.log statements with logger methods
This commit is contained in:
1 parent
78e0f41f5a
commit
5c561d87ce
16 files changed
+57
-27
No files matched your search
@@ -0,0 +1,22 @@
|
||||
const LOG_LEVEL = import.meta.env.VITE_APP_LOG_LEVEL;
|
||||
class Logger {
|
||||
constructor(logLevel) {
|
||||
const NO_OP = () => {};
|
||||
|
||||
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;
|
||||
}
|
||||
this.log = console.log.bind(console);
|
||||
}
|
||||
}
|
||||
|
||||
export const logger = new Logger(LOG_LEVEL);
|
||||
Reference in new issue
Block a user