header create
This commit is contained in:
1 parent
d877ecf061
commit
b852293447
4 files changed
+47
-12
No files matched your search
@@ -1,14 +1,25 @@
|
||||
import store from "../store";
|
||||
const LOG_LEVEL = import.meta.env.VITE_APP_LOG_LEVEL || "debug";
|
||||
const NO_OP = () => {};
|
||||
|
||||
class Logger {
|
||||
constructor() {
|
||||
let logLevel = LOG_LEVEL;
|
||||
this.unsubscribe = store.subscribe(() => {
|
||||
logLevel = "debug";
|
||||
this.updateLogLevel(logLevel);
|
||||
});
|
||||
this.updateLogLevel(logLevel);
|
||||
// Defer store subscription to avoid circular dependency during HMR
|
||||
setTimeout(() => {
|
||||
try {
|
||||
import("../store").then(({ default: store }) => {
|
||||
if (store) {
|
||||
this.unsubscribe = store.subscribe(() => {
|
||||
logLevel = "debug";
|
||||
this.updateLogLevel(logLevel);
|
||||
});
|
||||
}
|
||||
});
|
||||
} catch (e) {
|
||||
// Store not ready yet, ignore
|
||||
}
|
||||
}, 0);
|
||||
}
|
||||
|
||||
updateLogLevel(logLevel) {
|
||||
|
||||
Reference in new issue
Block a user