Merge pull request #5999 from antobinary/log-config-restructure

Restructure of clientLog configs
This commit is contained in:
Anton Georgiev 2018-08-22 16:44:09 -04:00 committed by GitHub
commit 8c6117d3a2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 20 additions and 17 deletions

View File

@ -16,7 +16,7 @@ import { nameFromLevel } from '@browser-bunyan/levels';
// externalURL is the end-point that logs will be sent to // externalURL is the end-point that logs will be sent to
// Call the logger by doing a function call with the level name, I.e, logger.warn('Hi on warn') // Call the logger by doing a function call with the level name, I.e, logger.warn('Hi on warn')
const LOG_CONFIG = Meteor.settings.public.clientLog || [{ target: 'console', level: 'info' }]; const LOG_CONFIG = Meteor.settings.public.clientLog || { console: { enabled: true, level: 'info' } };
const { fullInfo } = Auth; const { fullInfo } = Auth;
// Custom stream that logs to an end-point // Custom stream that logs to an end-point
@ -66,10 +66,15 @@ function createStreamForTarget(target, options) {
} }
function generateLoggerStreams(config) { function generateLoggerStreams(config) {
return config.map(({ target, level, ...streamOptions }) => ({ let result = [];
level, Object.keys(config).forEach((key) => {
stream: createStreamForTarget(target, streamOptions), const logOption = config[key];
})); if (logOption && logOption.enabled) {
const { level, ...streamOptions } = logOption;
result = result.concat({ level, stream: createStreamForTarget(key, streamOptions) });
}
});
return result;
} }
// Creates the logger with the array of streams of the chosen targets // Creates the logger with the array of streams of the chosen targets

View File

@ -351,12 +351,11 @@
] ]
} }
}, },
"clientLog": [ "clientLog": {
{ "server": { "enabled": true, "level": "info" },
"target": "server", "console": { "enabled": false, "level": "debug" },
"level": "info" "external": { "enabled": false, "level": "info", "url": "https://LOG_HOST/html5Log", "method": "POST" }
} }
]
}, },
"private": { "private": {

View File

@ -351,12 +351,11 @@
] ]
} }
}, },
"clientLog": [ "clientLog": {
{ "server": { "enabled": true, "level": "info" },
"target": "server", "console": { "enabled": false, "level": "debug" },
"level": "info" "external": { "enabled": false, "level": "info", "url": "https://LOG_HOST/html5Log", "method": "POST" }
} }
]
}, },
"private": { "private": {