34 lines
770 B
JavaScript
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;
|
|
}
|
|
}
|