bigbluebutton-Github/bigbluebutton-html5/imports/api/log-client/server/methods/logClient.js
2020-04-30 16:40:45 -04:00

32 lines
1013 B
JavaScript
Executable File

import Logger from '/imports/startup/server/logger';
import Users from '/imports/api/users';
const logClient = function (type, logDescription, logCode = 'was_not_provided', extraInfo = {}, userInfo = {}) {
const connectionId = this.connection.id;
const User = Users.findOne({ connectionId });
const logContents = {
logCode,
logDescription,
connectionId,
extraInfo,
userInfo,
};
if (User) { // TODO--
if ((userInfo.credentials && User.meetingId === userInfo.credentials.meetingId)
|| ((userInfo.meetingId && User.meetingId === userInfo.meetingId))) {
logContents.extraInfo.validUser = 'valid';
} else {
logContents.extraInfo.validUser = 'invalid';
}
} else {
logContents.extraInfo.validUser = 'notFound';
}
// If I don't pass message, logs will start with `undefined`
Logger.log({ message: JSON.stringify(logContents), level: type });
// Logger.log({ message: 'client->server', level: type, logContents });
};
export default logClient;