Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions apps/meteor/app/api/server/lib/eraseTeam.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ export async function eraseRoomLooseValidation(rid: string): Promise<boolean> {

try {
await deleteRoom(rid);
} catch (e) {
SystemLogger.error(e);
} catch (err) {
SystemLogger.error({ err });
return false;
}

Expand Down
20 changes: 9 additions & 11 deletions apps/meteor/app/apps/server/bridges/scheduler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,7 @@ export class AppSchedulerBridge extends SchedulerBridge {
);
break;
default:
this.orch
.getRocketChatLogger()
.error(`Invalid startup setting type (${String((startupSetting as any).type)}) for the processor ${id}`);
this.orch.getRocketChatLogger().error({ msg: 'Unknown startup setting type', type: (startupSetting as any).type });
break;
}
});
Expand All @@ -105,8 +103,8 @@ export class AppSchedulerBridge extends SchedulerBridge {
await this.startScheduler();
const job = await this.scheduler.schedule(when, id, this.decorateJobData(data, appId));
return job.attrs._id.toString();
} catch (e) {
this.orch.getRocketChatLogger().error(e);
} catch (err) {
this.orch.getRocketChatLogger().error({ err });
}
}

Expand Down Expand Up @@ -140,8 +138,8 @@ export class AppSchedulerBridge extends SchedulerBridge {
skipImmediate,
});
return job.attrs._id.toString();
} catch (e) {
this.orch.getRocketChatLogger().error(e);
} catch (err) {
this.orch.getRocketChatLogger().error({ err });
}
}

Expand All @@ -167,8 +165,8 @@ export class AppSchedulerBridge extends SchedulerBridge {

try {
await this.scheduler.cancel(cancelQuery);
} catch (e) {
this.orch.getRocketChatLogger().error(e);
} catch (err) {
this.orch.getRocketChatLogger().error({ err });
}
}

Expand All @@ -185,8 +183,8 @@ export class AppSchedulerBridge extends SchedulerBridge {
const matcher = new RegExp(`_${appId}$`);
try {
await this.scheduler.cancel({ name: { $regex: matcher } });
} catch (e) {
this.orch.getRocketChatLogger().error(e);
} catch (err) {
this.orch.getRocketChatLogger().error({ err });
}
}

Expand Down
2 changes: 1 addition & 1 deletion apps/meteor/app/file-upload/server/lib/FileUpload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ export const FileUpload = {
try {
await writeFile(tempFilePath, data);
} catch (err: any) {
SystemLogger.error(err);
SystemLogger.error({ err });
}

await this.getCollection().updateOne(
Expand Down
4 changes: 2 additions & 2 deletions apps/meteor/app/file-upload/server/lib/requests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ WebApp.connectHandlers.use(FileUpload.getPath(), async (req, res, next) => {
try {
url = await store.getStore().getRedirectURL(file, false);
expiryTimespan = await store.getStore().getUrlExpiryTimeSpan();
} catch (e) {
SystemLogger.debug(e);
} catch (err) {
SystemLogger.debug({ err });
}
return FileUpload.respondWithRedirectUrlInfo(url, file, req, res, expiryTimespan);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,9 @@ export class PendingFileImporter extends Importer {
// Update progress more often on large files
this.reportProgress();
});
res.on('error', async (error) => {
res.on('error', async (err) => {
await completeFile(details);
logError(error);
logError({ err });
});

res.on('end', async () => {
Expand All @@ -145,14 +145,14 @@ export class PendingFileImporter extends Importer {
await Messages.setImportFileRocketChatAttachment(_importFile.id, url, attachment);
await completeFile(details);
importedRoomIds.add(message.rid);
} catch (error) {
} catch (err) {
await completeFile(details);
logError(error);
logError({ err });
}
});
});
} catch (error) {
this.logger.error(error);
} catch (err) {
this.logger.error({ err });
}
}

Expand Down
20 changes: 10 additions & 10 deletions apps/meteor/app/importer-slack/server/SlackImporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -290,8 +290,8 @@ export class SlackImporter extends Importer {
ImporterWebsocket.progressUpdated({ rate });
oldRate = rate;
}
} catch (e) {
this.logger.error(e);
} catch (err) {
this.logger.error({ msg: 'Error updating progress', err });
}
};

Expand Down Expand Up @@ -332,8 +332,8 @@ export class SlackImporter extends Importer {
increaseProgress();
continue;
}
} catch (e) {
this.logger.error(e);
} catch (err) {
this.logger.error({ msg: 'Error adding missed type', err });
}
}

Expand Down Expand Up @@ -388,19 +388,19 @@ export class SlackImporter extends Importer {
this.logger.warn({ msg: 'Entry is not a valid JSON file; unable to import', entryName: entry.entryName, err: error });
}
}
} catch (e) {
this.logger.error(e);
} catch (err) {
this.logger.error({ msg: 'Error processing message entry', err });
}

increaseProgress();
}

if (Object.keys(missedTypes).length > 0) {
this.logger.info('Missed import types:', missedTypes);
this.logger.info({ msg: 'Missed import types', missedTypes });
}
} catch (e) {
this.logger.error(e);
throw e;
} catch (err) {
this.logger.error({ msg: 'Error preparing import using local file', err });
throw err;
}

ImporterWebsocket.progressUpdated({ rate: 100 });
Expand Down
4 changes: 3 additions & 1 deletion apps/meteor/app/integrations/server/lib/ScriptEngine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,9 @@ export abstract class IntegrationScriptEngine<IsIncoming extends boolean> {
});

this.logger.debug({
msg: `Script method "${method}" result of the Integration "${integration.name}" is:`,
msg: 'Script method result of the Integration',
method,
integration: integration.name,
result,
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export class IsolatedVMScriptEngine<IsIncoming extends boolean> extends Integrat
const script = integration.scriptCompiled;
try {
this.logger.info({ msg: 'Will evaluate the integration script', integration: pick(integration, 'name', '_id') });
this.logger.debug(script);
this.logger.debug({ script });

const isolate = new ivm.Isolate({ memoryLimit: 8 });

Expand Down
6 changes: 3 additions & 3 deletions apps/meteor/app/integrations/server/lib/triggerHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -782,12 +782,12 @@ class RocketChatIntegrationHandler {
}
}
})
.catch(async (error) => {
outgoingLogger.error(error);
.catch(async (err) => {
outgoingLogger.error({ err });
await updateHistory({
historyId,
step: 'after-http-call',
httpError: error,
httpError: err,
httpResult: null,
});
});
Expand Down
2 changes: 1 addition & 1 deletion apps/meteor/app/lib/server/functions/saveUserIdentity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ export async function saveUserIdentity({
try {
await updateUsernameReferences(handleUpdateParams);
} catch (err) {
SystemLogger.error(err);
SystemLogger.error({ err });
}
});
} else {
Expand Down
4 changes: 2 additions & 2 deletions apps/meteor/app/lib/server/functions/setUsername.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,8 @@ export const _setUsername = async function (
setImmediate(() => {
Accounts.sendEnrollmentEmail(user._id);
});
} catch (e: any) {
SystemLogger.error(e);
} catch (err: any) {
SystemLogger.error({ err });
}
}, session);
}
Expand Down
4 changes: 2 additions & 2 deletions apps/meteor/app/livechat/server/lib/rooms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -254,8 +254,8 @@ export async function returnRoomAsInquiry(room: IOmnichannelRoom, departmentId?:
try {
await saveTransferHistory(room, transferData);
await RoutingManager.unassignAgent(inquiry, departmentId);
} catch (e) {
livechatLogger.error(e);
} catch (err) {
livechatLogger.error({ err });
throw new Meteor.Error('error-returning-inquiry');
}

Expand Down
3 changes: 2 additions & 1 deletion apps/meteor/app/livechat/server/lib/stream/agentStatus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ export const onlineAgents = {
}
} catch (e) {
logger.error({
msg: `Cannot perform action ${action}`,
msg: 'Cannot perform action',
action,
err: e,
});
}
Expand Down
4 changes: 2 additions & 2 deletions apps/meteor/app/livechat/server/sendMessageBySMS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ callbacks.add(
phoneNumber: visitor.phone[0].phoneNumber,
service,
});
} catch (e) {
callbackLogger.error(e);
} catch (err) {
callbackLogger.error({ msg: 'Error sending SMS message', err });
}

return message;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,12 @@ export const unsubscribe = async function (_id: string, createdAt: string): Prom
if (_id && createdAt) {
const affectedRows = (await Users.rocketMailUnsubscribe(_id, createdAt)) === 1;

SystemLogger.debug('[Mailer:Unsubscribe]', _id, createdAt, new Date(parseInt(createdAt)), affectedRows);
SystemLogger.debug({
msg: '[Mailer:Unsubscribe]',
_id,
createdAt,
affectedRows,
});

return affectedRows;
}
Expand Down
19 changes: 9 additions & 10 deletions apps/meteor/app/meteor-accounts-saml/server/lib/SAML.ts
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ export class SAML {
}

private static async _logoutRemoveTokens(userId: string): Promise<void> {
SAMLUtils.log(`Found user ${userId}`);
SAMLUtils.log({ msg: 'Found user', userId });

await Users.unsetLoginTokens(userId);
await Users.removeSamlServiceSession(userId);
Expand Down Expand Up @@ -342,16 +342,16 @@ export class SAML {

redirect(url);
});
} catch (e: any) {
SystemLogger.error(e);
} catch (err: any) {
SystemLogger.error({ err });
redirect();
}
});
}

private static async processLogoutResponse(req: IIncomingMessage, res: ServerResponse, service: IServiceProviderOptions): Promise<void> {
if (!req.query.SAMLResponse) {
SAMLUtils.error('Invalid LogoutResponse, missing SAMLResponse', req.query);
SAMLUtils.error({ msg: 'Invalid LogoutResponse received: missing SAMLResponse parameter.', query: req.query });
throw new Error('Invalid LogoutResponse received.');
}

Expand All @@ -366,7 +366,7 @@ export class SAML {
}

const logOutUser = async (inResponseTo: string): Promise<void> => {
SAMLUtils.log(`Logging Out user via inResponseTo ${inResponseTo}`);
SAMLUtils.log({ msg: 'Processing logout for inResponseTo', inResponseTo });

const loggedOutUsers = await Users.findBySAMLInResponseTo(inResponseTo).toArray();
if (loggedOutUsers.length > 1) {
Expand Down Expand Up @@ -410,8 +410,7 @@ export class SAML {
try {
url = await serviceProvider.getAuthorizeUrl(samlObject.credentialToken);
} catch (err: any) {
SAMLUtils.error('Unable to generate authorize url');
SAMLUtils.error(err);
SAMLUtils.error({ err, msg: 'Unable to generate authorize url' });
url = Meteor.absoluteUrl();
}

Expand Down Expand Up @@ -455,8 +454,8 @@ export class SAML {
Location: url,
});
res.end();
} catch (error) {
SAMLUtils.error(error);
} catch (err) {
SAMLUtils.error({ err });
res.writeHead(302, {
Location: Meteor.absoluteUrl(),
});
Expand Down Expand Up @@ -521,7 +520,7 @@ export class SAML {
}
}
} catch (err: any) {
SystemLogger.error(err);
SystemLogger.error({ err });
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,7 @@ export class SAMLServiceProvider {

public async getAuthorizeUrl(credentialToken: string): Promise<string | undefined> {
const request = this.generateAuthorizeRequest(credentialToken);
SAMLUtils.log('-----REQUEST------');
SAMLUtils.log(request);
SAMLUtils.log({ request, msg: 'getAuthorizeUrl' });

return this.requestToUrl(request, 'authorize');
}
Expand Down
17 changes: 8 additions & 9 deletions apps/meteor/app/meteor-accounts-saml/server/lib/Utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export class SAMLUtils {
}

public static getServiceProviderOptions(providerName: string): IServiceProviderOptions | undefined {
this.log(providerName, providerList);
this.log({ providerName, providerList });

return providerList.find((providerOptions) => providerOptions.provider === providerName);
}
Expand Down Expand Up @@ -133,15 +133,15 @@ export class SAMLUtils {
return `saml/${credentialToken}?saml_idp_credentialToken=${credentialToken}`;
}

public static log(obj: any, ...args: Array<any>): void {
public static log(obj: object | string): void {
if (debug && logger) {
logger.debug(obj, ...args);
logger.debug(obj);
}
}

public static error(obj: any, ...args: Array<any>): void {
public static error(obj: object | string): void {
if (logger) {
logger.error(obj, ...args);
logger.error(obj);
}
}

Expand Down Expand Up @@ -219,9 +219,8 @@ export class SAMLUtils {

try {
map = JSON.parse(userDataFieldMap);
} catch (e) {
SAMLUtils.log(userDataFieldMap);
SAMLUtils.log(e);
} catch (err) {
SAMLUtils.log({ userDataFieldMap, err });
throw new Error('Failed to parse custom user field map');
}

Expand Down Expand Up @@ -412,7 +411,7 @@ export class SAMLUtils {

public static mapProfileToUserObject(profile: Record<string, any>): ISAMLUser {
const userDataMap = this.getUserDataMapping();
SAMLUtils.log('parsed userDataMap', userDataMap);
SAMLUtils.log({ msg: 'Mapping SAML Profile to User Object', userDataMap });

if (userDataMap.identifier.type === 'custom') {
if (!userDataMap.identifier.attribute) {
Expand Down
Loading
Loading