2017-12-22 15:24:31 +00:00
|
|
|
/*
|
|
|
|
* @flow
|
|
|
|
*/
|
2017-03-02 13:10:10 +00:00
|
|
|
import { windowOrGlobal } from './';
|
|
|
|
|
2017-12-22 15:24:31 +00:00
|
|
|
import type ModuleBase from './ModuleBase';
|
|
|
|
|
2017-03-02 13:10:10 +00:00
|
|
|
((base) => {
|
|
|
|
window = base || window;
|
|
|
|
if (!window.localStorage) window.localStorage = {};
|
|
|
|
})(windowOrGlobal);
|
|
|
|
|
2017-06-29 16:24:34 +00:00
|
|
|
// clean up time
|
2017-03-02 13:10:10 +00:00
|
|
|
|
2017-12-22 15:24:31 +00:00
|
|
|
const NATIVE_LOGGERS: { [ModuleBase]: Object } = {};
|
|
|
|
|
2018-01-03 20:00:38 +00:00
|
|
|
export const getLogger = (module: ModuleBase) => NATIVE_LOGGERS[module];
|
|
|
|
|
|
|
|
export const initialiseLogger = (module: ModuleBase, logNamespace: string) => {
|
2017-12-22 15:24:31 +00:00
|
|
|
if (!NATIVE_LOGGERS[module]) {
|
2018-01-03 20:00:38 +00:00
|
|
|
NATIVE_LOGGERS[module] = require('bows')(`🔥 ${logNamespace.toUpperCase()}`);
|
2017-12-22 15:24:31 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2017-06-29 16:24:34 +00:00
|
|
|
export default class Log {
|
|
|
|
static createLogger(namespace) {
|
|
|
|
return require('bows')(namespace);
|
2017-03-02 13:10:10 +00:00
|
|
|
}
|
|
|
|
|
2017-06-29 16:24:34 +00:00
|
|
|
static setLevel(booleanOrDebugString) {
|
|
|
|
window.localStorage.debug = booleanOrDebugString;
|
|
|
|
window.localStorage.debugColors = !!booleanOrDebugString;
|
2017-03-02 13:10:10 +00:00
|
|
|
}
|
|
|
|
}
|