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/v1/emoji-custom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,8 @@ API.v1.addRoute(
});

await uploadEmojiCustomWithBuffer(this.userId, fileBuffer, mimetype, emojiData);
} catch (e) {
SystemLogger.error(e);
} catch (err) {
SystemLogger.error({ err });
return API.v1.failure();
}

Expand Down
4 changes: 2 additions & 2 deletions apps/meteor/app/api/server/v1/ldap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ API.v1.addRoute(

try {
await LDAP.testConnection();
} catch (error) {
SystemLogger.error(error);
} catch (err) {
SystemLogger.error({ err });
throw new Error('Connection_failed');
}

Expand Down
4 changes: 2 additions & 2 deletions apps/meteor/app/api/server/v1/misc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,7 @@ API.v1.addRoute(
return API.v1.success(mountResult({ id, result }));
} catch (err) {
if (!(err as any).isClientSafe && !(err as any).meteorError) {
SystemLogger.error({ msg: `Exception while invoking method ${method}`, err });
SystemLogger.error({ msg: 'Exception while invoking method', err, method });
}

if (settings.get('Log_Level') === '2') {
Expand Down Expand Up @@ -576,7 +576,7 @@ API.v1.addRoute(
return API.v1.success(mountResult({ id, result }));
} catch (err) {
if (!(err as any).isClientSafe && !(err as any).meteorError) {
SystemLogger.error({ msg: `Exception while invoking method ${method}`, err });
SystemLogger.error({ msg: 'Exception while invoking method', err, method });
}
if (settings.get('Log_Level') === '2') {
Meteor._debug(`Exception while invoking method ${method}`, err);
Expand Down
11 changes: 8 additions & 3 deletions apps/meteor/app/authentication/server/lib/logLoginAttempts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,12 @@ export const logFailedLoginAttempts = (login: ILoginAttempt): void => {
if (!settings.get('Login_Logs_UserAgent')) {
userAgent = '-';
}
SystemLogger.info(
`Failed login detected - Username[${user}] ClientAddress[${clientAddress}] ForwardedFor[${forwardedFor}] XRealIp[${realIp}] UserAgent[${userAgent}]`,
);
SystemLogger.info({
msg: 'Failed login detected',
user,
clientAddress,
forwardedFor,
realIp,
userAgent,
});
};
20 changes: 10 additions & 10 deletions apps/meteor/app/cloud/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,36 +23,36 @@ Meteor.startup(async () => {
}

console.log('Successfully registered with token provided by REG_TOKEN!');
} catch (e: any) {
SystemLogger.error('An error occurred registering with token.', e.message);
} catch (err: any) {
SystemLogger.error({ msg: 'An error occurred registering with token.', err });
}
}

setImmediate(async () => {
try {
await syncWorkspace();
} catch (e: any) {
if (e instanceof CloudWorkspaceAccessTokenEmptyError) {
} catch (err: any) {
if (err instanceof CloudWorkspaceAccessTokenEmptyError) {
return;
}
if (e.type && e.type === 'AbortError') {
if (err.type && err.type === 'AbortError') {
return;
}
SystemLogger.error('An error occurred syncing workspace.', e.message);
SystemLogger.error({ msg: 'An error occurred syncing workspace.', err });
}
});
const minute = Math.floor(Math.random() * 60);
await cronJobs.add(licenseCronName, `${minute} */12 * * *`, async () => {
try {
await syncWorkspace();
} catch (e: any) {
if (e instanceof CloudWorkspaceAccessTokenEmptyError) {
} catch (err: any) {
if (err instanceof CloudWorkspaceAccessTokenEmptyError) {
return;
}
if (e.type && e.type === 'AbortError') {
if (err.type && err.type === 'AbortError') {
return;
}
SystemLogger.error('An error occurred syncing workspace.', e.message);
SystemLogger.error({ msg: 'An error occurred syncing workspace.', err });
}
});
});
Expand Down
4 changes: 2 additions & 2 deletions apps/meteor/app/crowd/server/crowd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -392,8 +392,8 @@ Accounts.registerLoginHandler('crowd', async function (this: typeof Accounts, lo

return result;
} catch (err: any) {
logger.debug({ err });
logger.error('Crowd user not authenticated due to an error');
logger.error({ msg: 'Crowd user not authenticated due to an error', err });

throw new Meteor.Error('user-not-found', err.message);
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ export const parseFileIntoMessageAttachments = async (
typeGroup: thumbnail.typeGroup || '',
});
}
} catch (e) {
SystemLogger.error(e);
} catch (err) {
SystemLogger.error({ err });
}
attachments.push(attachment);
} else if (/^audio\/.+/.test(file.type as string)) {
Expand Down
8 changes: 4 additions & 4 deletions apps/meteor/app/file-upload/ufs/AmazonS3/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ class AmazonS3Store extends UploadFS.Store {
try {
return s3.deleteObject(params).promise();
} catch (err: any) {
SystemLogger.error(err);
SystemLogger.error({ err });
}
};

Expand Down Expand Up @@ -184,9 +184,9 @@ class AmazonS3Store extends UploadFS.Store {
ContentType: file.type,
Bucket: classOptions.connection.params.Bucket,
},
(error) => {
if (error) {
SystemLogger.error(error);
(err) => {
if (err) {
SystemLogger.error({ err });
}

writeStream.emit('real_finish');
Expand Down
2 changes: 1 addition & 1 deletion apps/meteor/app/file-upload/ufs/GoogleStorage/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ class GoogleStorageStore extends UploadFS.Store {
try {
return bucket.file(this.getPath(file)).delete();
} catch (err: any) {
SystemLogger.error(err);
SystemLogger.error({ err });
}
};

Expand Down
2 changes: 1 addition & 1 deletion apps/meteor/app/file-upload/ufs/Webdav/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ class WebdavStore extends UploadFS.Store {
try {
return client.deleteFile(this.getPath(file));
} catch (err: any) {
SystemLogger.error(err);
SystemLogger.error({ err });
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,8 @@ export class MessageConverter extends RecordConverter<IImportMessageRecord> {
for await (const rid of this.rids) {
try {
await Rooms.resetLastMessageById(rid, null);
} catch (e) {
this._logger.warn({ msg: 'Failed to update last message of room', roomId: rid });
this._logger.error(e);
} catch (err) {
this._logger.error({ msg: 'Failed to update last message of room', roomId: rid, err });
}
}
}
Expand All @@ -70,9 +69,8 @@ export class MessageConverter extends RecordConverter<IImportMessageRecord> {

try {
await insertMessage(creator, msgObj as unknown as IDBMessage, rid, true);
} catch (e) {
this._logger.warn({ msg: 'Failed to import message', timestamp: msgObj.ts, roomId: rid });
this._logger.error(e);
} catch (err) {
this._logger.error({ msg: 'Failed to import message', timestamp: msgObj.ts, roomId: rid, err });
}
}

Expand Down Expand Up @@ -167,7 +165,7 @@ export class MessageConverter extends RecordConverter<IImportMessageRecord> {
}

if (!data.username) {
this._logger.debug(importId);
this._logger.debug({ msg: 'Mentioned user has no username', importId });
throw new Error('importer-message-mentioned-username-not-found');
}

Expand Down
7 changes: 4 additions & 3 deletions apps/meteor/app/integrations/server/lib/triggerHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,10 @@ class RocketChatIntegrationHandler {

// If no room could be found, we won't be sending any messages but we'll warn in the logs
if (!tmpRoom) {
outgoingLogger.warn(
`The Integration "${trigger.name}" doesn't have a room configured nor did it provide a room to send the message to.`,
);
outgoingLogger.warn({
msg: 'The Integration doesnt have a room configured nor did it provide a room to send the message to.',
integrationName: trigger.name,
});
return;
}

Expand Down
8 changes: 4 additions & 4 deletions apps/meteor/app/settings/server/CachedSettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ export class CachedSettings
*/
public override has(_id: ISetting['_id']): boolean {
if (!this.ready && warn) {
SystemLogger.warn(`Settings not initialized yet. getting: ${_id}`);
SystemLogger.warn({ msg: 'Settings not initialized yet. getting', _id });
}
return this.store.has(_id);
}
Expand All @@ -120,7 +120,7 @@ export class CachedSettings
*/
public getSetting(_id: ISetting['_id']): ISetting | undefined {
if (!this.ready && warn) {
SystemLogger.warn(`Settings not initialized yet. getting: ${_id}`);
SystemLogger.warn({ msg: 'Settings not initialized yet. getting', _id });
}
return this.store.get(_id);
}
Expand All @@ -134,7 +134,7 @@ export class CachedSettings
*/
public get<T extends SettingValue = SettingValue>(_id: ISetting['_id']): T {
if (!this.ready && warn) {
SystemLogger.warn(`Settings not initialized yet. getting: ${_id}`);
SystemLogger.warn({ msg: 'Settings not initialized yet. getting', _id });
}
return this.store.get(_id)?.value as T;
}
Expand All @@ -148,7 +148,7 @@ export class CachedSettings
*/
public getByRegexp<T extends SettingValue = SettingValue>(_id: RegExp): [string, T][] {
if (!this.ready && warn) {
SystemLogger.warn(`Settings not initialized yet. getting: ${_id}`);
SystemLogger.warn({ msg: 'Settings not initialized yet. getting', _id });
}

return [...this.store.entries()].filter(([key]) => _id.test(key)).map(([key, setting]) => [key, setting.value]) as [string, T][];
Expand Down
6 changes: 3 additions & 3 deletions apps/meteor/app/settings/server/SettingsRegistry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ export class SettingsRegistry {
);

if (isSettingEnterprise(settingFromCode) && !('invalidValue' in settingFromCode)) {
SystemLogger.error(`Enterprise setting ${_id} is missing the invalidValue option`);
SystemLogger.error({ msg: 'Enterprise setting is missing the invalidValue option', _id });
throw new Error(`Enterprise setting ${_id} is missing the invalidValue option`);
}

Expand All @@ -145,7 +145,7 @@ export class SettingsRegistry {
try {
validateSetting(settingFromCode._id, settingFromCode.type, settingFromCode.value);
} catch (e) {
IS_DEVELOPMENT && SystemLogger.error(`Invalid setting code ${_id}: ${(e as Error).message}`);
IS_DEVELOPMENT && SystemLogger.error({ msg: 'Invalid setting code', _id, err: e as Error });
}

const isOverwritten = settingFromCode !== settingFromCodeOverwritten || (settingStored && settingStored !== settingStoredOverwritten);
Expand Down Expand Up @@ -189,7 +189,7 @@ export class SettingsRegistry {
try {
validateSetting(settingFromCode._id, settingFromCode.type, settingStored?.value);
} catch (e) {
IS_DEVELOPMENT && SystemLogger.error(`Invalid setting stored ${_id}: ${(e as Error).message}`);
IS_DEVELOPMENT && SystemLogger.error({ msg: 'Invalid setting stored', _id, err: e as Error });
}
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const handleAfterOnHold = async (room: Pick<IOmnichannelRoom, '_id'>): Promise<a
return;
}

cbLogger.debug(`Scheduling room ${rid} to be closed in ${autoCloseOnHoldChatTimeout} seconds`);
cbLogger.debug({ msg: 'Scheduling room to be closed', rid, autoCloseOnHoldChatTimeout });
const closeComment =
settings.get<string>('Livechat_auto_close_on_hold_chats_custom_message') ||
i18n.t('Closed_automatically_because_chat_was_onhold_for_seconds', {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const handleAfterOnHoldChatResumed = async (room: IRoom): Promise<IRoom> => {

const { _id: roomId } = room;

cbLogger.debug(`Removing current on hold timers for room ${roomId}`);
cbLogger.debug({ msg: 'Removing current on hold timers for room', roomId });
await AutoCloseOnHoldScheduler.unscheduleRoom(roomId);

return room;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,12 @@ const validateMaxChats = async ({
}

if (!settings.get('Livechat_waiting_queue')) {
cbLogger.info(`Chat can be taken by Agent ${agentId}: waiting queue is disabled`);
cbLogger.info({ msg: 'Chat can be taken by Agent: waiting queue is disabled', agentId });
return agent;
}

if (await allowAgentSkipQueue(agent)) {
cbLogger.info(`Chat can be taken by Agent ${agentId}: agent can skip queue`);
cbLogger.info({ msg: 'Chat can be taken by Agent: agent can skip queue', agentId });
return agent;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const resumeOnHoldCommentAndUser = async (room: IOmnichannelRoom): Promise<{ com
projection: { name: 1, username: 1 },
});
if (!visitor) {
callbackLogger.error(`[afterOmnichannelSaveMessage] Visitor Not found for room ${rid} while trying to resume on hold`);
callbackLogger.error({ msg: '[afterOmnichannelSaveMessage] Visitor Not found for room while trying to resume on hold', rid });
throw new Error('Visitor not found while trying to resume on hold');
}

Expand All @@ -26,7 +26,7 @@ const resumeOnHoldCommentAndUser = async (room: IOmnichannelRoom): Promise<{ com

const resumedBy = await Users.findOneById('rocket.cat');
if (!resumedBy) {
callbackLogger.error(`[afterOmnichannelSaveMessage] User Not found for room ${rid} while trying to resume on hold`);
callbackLogger.error({ msg: '[afterOmnichannelSaveMessage] User Not found for room while trying to resume on hold', rid });
throw new Error(`User not found while trying to resume on hold`);
}

Expand All @@ -53,13 +53,13 @@ callbacks.add(
}

if (isMessageFromVisitor(message) && room.onHold) {
callbackLogger.debug(`[afterOmnichannelSaveMessage] Room ${rid} is on hold, resuming it now since visitor sent a message`);
callbackLogger.debug({ msg: '[afterOmnichannelSaveMessage] Room is on hold, resuming it now since visitor sent a message', rid });

try {
const { comment: resumeChatComment, resumedBy } = await resumeOnHoldCommentAndUser(updatedRoom);
await OmnichannelEEService.resumeRoomOnHold(updatedRoom, resumeChatComment, resumedBy);
} catch (error) {
callbackLogger.error(`[afterOmnichannelSaveMessage] Error while resuming room ${rid} on hold: Error: `, error);
callbackLogger.error({ msg: '[afterOmnichannelSaveMessage] Error while resuming room on hold', rid, err: error });
return message;
}
}
Expand Down
4 changes: 2 additions & 2 deletions apps/meteor/server/lib/ldap/Manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ export class LDAPManager {
// Do a search as the user and check if they have any result
authLogger.debug('User authenticated successfully, performing additional search.');
if ((await ldap.searchAndCount(ldapUser.dn, {})) === 0) {
authLogger.debug(`Bind successful but user ${ldapUser.dn} was not found via search`);
authLogger.debug({ msg: 'Bind successful but user was not found via search', dn: ldapUser.dn });
}
}
return ldapUser;
Expand All @@ -267,7 +267,7 @@ export class LDAPManager {
// Do a search as the user and check if they have any result
authLogger.debug('User authenticated successfully, performing additional search.');
if ((await ldap.searchAndCount(ldapUser.dn, {})) === 0) {
authLogger.debug(`Bind successful but user ${ldapUser.dn} was not found via search`);
authLogger.debug({ msg: 'Bind successful but user was not found via search', dn: ldapUser.dn });
}
}

Expand Down
2 changes: 1 addition & 1 deletion apps/meteor/server/modules/streamer/streamer.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export abstract class Streamer<N extends keyof StreamerEvents> extends EventEmit
}

if (typeof fn === 'string' && ['all', 'none', 'logged'].indexOf(fn) === -1) {
SystemLogger.error(`${name} shortcut '${fn}' is invalid`);
SystemLogger.error({ msg: 'shortcut is invalid', name, fn });
}

if (fn === 'all' || fn === true) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export class OmnichannelAnalyticsService extends ServiceClassInternal implements
}

if (!this.agentOverview.isActionAllowed(name)) {
serviceLogger.error(`AgentOverview.${name} is not a valid action`);
serviceLogger.error({ msg: 'AgentOverview action is not valid', name });
return;
}

Expand All @@ -74,7 +74,7 @@ export class OmnichannelAnalyticsService extends ServiceClassInternal implements

// Check if function exists, prevent server error in case property altered
if (!this.chart.isActionAllowed(chartLabel)) {
serviceLogger.error(`ChartData.${chartLabel} is not a valid action`);
serviceLogger.error({ msg: 'ChartData action is not valid', chartLabel });
return;
}

Expand Down Expand Up @@ -164,7 +164,7 @@ export class OmnichannelAnalyticsService extends ServiceClassInternal implements
}

if (!this.overview.isActionAllowed(name)) {
serviceLogger.error(`OverviewData.${name} is not a valid action`);
serviceLogger.error({ msg: 'OverviewData action is not valid', name });
return;
}

Expand Down
Loading
Loading