react-native-firebase/lib/utils/log.js

35 lines
835 B
JavaScript
Raw Normal View History

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