matterbridge-xiaomi-roborock
Version:
Matterbridge Xiaomi Roborock Plugin
17 lines (16 loc) • 589 B
JavaScript
export function getLogger(log, config) {
if ('setModel' in log) {
return log;
}
let model = 'unknown';
function buildMsg(message) {
return `[Name=${config.name}][Model=${model}] ${message}`;
}
return {
debug: (msg, ...params) => log.debug(buildMsg(msg), ...params),
info: (msg, ...params) => log.info(buildMsg(msg), ...params),
warn: (msg, ...params) => log.warn(buildMsg(msg), ...params),
error: (msg, ...params) => log.error(buildMsg(msg), ...params),
setModel: (modelName) => (model = modelName),
};
}