bigbluebutton-Github/bigbluebutton-html5/imports/api/log-client/server/methods/logClient.js
Anton Georgiev b99cc7f413
Merge pull request #5923 from MaximKhlobystov/client-logging-error
Fix for the client logging error
2018-07-30 14:10:16 -04:00

29 lines
862 B
JavaScript
Executable File

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 });
const logContents = { fullInfo };
if (User) {
if (User.meetingId === fullInfo.credentials.meetingId) {
logContents.validUser = 'valid';
} else {
logContents.validUser = 'invalid';
}
} else {
logContents.validUser = 'notFound';
}
const topic = typeof logContents == 'Object' ? logContents.topic : null;
if (typeof log === 'string' || log instanceof String) {
Logger.log(type, `${topic || 'CLIENT'} LOG: ${log}\n`, logContents);
} else {
Logger.log(type, `${topic || 'CLIENT'} LOG: ${JSON.stringify(log)}\n`, logContents);
}
};
export default logClient;