bigbluebutton-Github/bigbluebutton-html5/imports/api/log-client/server/methods/logClient.js

38 lines
1.0 KiB
JavaScript
Raw Normal View History

2017-04-28 21:47:07 +08:00
import Logger from '/imports/startup/server/logger';
import Users from '/imports/api/users';
const logClient = function (type, log, fullInfo = {}) {
const SERVER_CONN_ID = this.connection.id;
const User = Users.findOne({ connectionId: SERVER_CONN_ID });
2018-07-26 03:59:14 +08:00
const logContents = { fullInfo };
if (User) {
if ((fullInfo.credentials && User.meetingId === fullInfo.credentials.meetingId)
|| ((fullInfo.meetingId && User.meetingId === fullInfo.meetingId))) {
2018-07-26 03:59:14 +08:00
logContents.validUser = 'valid';
2018-06-20 00:46:59 +08:00
} else {
2018-07-26 03:59:14 +08:00
logContents.validUser = 'invalid';
2018-06-20 00:46:59 +08:00
}
} else {
2018-07-26 03:59:14 +08:00
logContents.validUser = 'notFound';
}
2017-04-28 21:47:07 +08:00
const topic = typeof logContents === 'Object' ? logContents.topic : null;
2018-03-22 03:39:11 +08:00
if (typeof log === 'string' || log instanceof String) {
Logger.log({
level: type,
message: `${topic || 'CLIENT'} LOG: ${log}\n`,
meta: logContents,
});
2018-03-22 03:39:11 +08:00
} else {
Logger.log({
level: type,
message: `${topic || 'CLIENT'} LOG: ${JSON.stringify(log)}\n`,
meta: logContents,
});
2018-03-22 03:39:11 +08:00
}
2017-06-06 03:12:06 +08:00
};
export default logClient;