[internals][types] Fix a couple of minor issues

This commit is contained in:
Chris Bianca
2018-01-05 18:23:38 +00:00
parent 80cb54ee6d
commit d1f2b3fcfa
9 changed files with 32 additions and 27 deletions

View File

@@ -13,13 +13,19 @@ import type ModuleBase from './ModuleBase';
// clean up time
const NATIVE_LOGGERS: { [ModuleBase]: Object } = {};
const NATIVE_LOGGERS: { [string]: Object } = {};
export const getLogger = (module: ModuleBase) => NATIVE_LOGGERS[module];
const getModuleKey = (module: ModuleBase): string => `${module.app.name}:${module.namespace}`;
export const getLogger = (module: ModuleBase) => {
const key = getModuleKey(module);
return NATIVE_LOGGERS[key];
};
export const initialiseLogger = (module: ModuleBase, logNamespace: string) => {
if (!NATIVE_LOGGERS[module]) {
NATIVE_LOGGERS[module] = require('bows')(`🔥 ${logNamespace.toUpperCase()}`);
const key = getModuleKey(module);
if (!NATIVE_LOGGERS[key]) {
NATIVE_LOGGERS[key] = require('bows')(`🔥 ${logNamespace.toUpperCase()}`);
}
};