Merge pull request #5999 from antobinary/log-config-restructure
Restructure of clientLog configs
This commit is contained in:
commit
8c6117d3a2
@ -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
|
||||||
|
@ -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": {
|
||||||
|
@ -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": {
|
||||||
|
Loading…
Reference in New Issue
Block a user