2
0
mirror of synced 2025-01-12 15:14:39 +00:00

34 lines
770 B
JavaScript

/*
* @flow
*/
import { windowOrGlobal } from './';
import type ModuleBase from './ModuleBase';
((base) => {
window = base || window;
if (!window.localStorage) window.localStorage = {};
})(windowOrGlobal);
// clean up time
const NATIVE_LOGGERS: { [ModuleBase]: Object } = {};
export const getLogger = (module: ModuleBase) => {
if (!NATIVE_LOGGERS[module]) {
NATIVE_LOGGERS[module] = require('bows')(`🔥 ${module._namespace.toUpperCase()}`);
}
return NATIVE_LOGGERS[module];
};
export default class Log {
static createLogger(namespace) {
return require('bows')(namespace);
}
static setLevel(booleanOrDebugString) {
window.localStorage.debug = booleanOrDebugString;
window.localStorage.debugColors = !!booleanOrDebugString;
}
}