diff --git a/apps/meteor/app/api/server/v1/emoji-custom.ts b/apps/meteor/app/api/server/v1/emoji-custom.ts index fa84d3cc6b995..15764b7f74e7d 100644 --- a/apps/meteor/app/api/server/v1/emoji-custom.ts +++ b/apps/meteor/app/api/server/v1/emoji-custom.ts @@ -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(); } diff --git a/apps/meteor/app/api/server/v1/ldap.ts b/apps/meteor/app/api/server/v1/ldap.ts index 4b112cfbf3351..3f9a2c29deded 100644 --- a/apps/meteor/app/api/server/v1/ldap.ts +++ b/apps/meteor/app/api/server/v1/ldap.ts @@ -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'); } diff --git a/apps/meteor/app/api/server/v1/misc.ts b/apps/meteor/app/api/server/v1/misc.ts index 403ffcc29b4ce..192a3e3579dc0 100644 --- a/apps/meteor/app/api/server/v1/misc.ts +++ b/apps/meteor/app/api/server/v1/misc.ts @@ -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') { @@ -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); diff --git a/apps/meteor/app/authentication/server/lib/logLoginAttempts.ts b/apps/meteor/app/authentication/server/lib/logLoginAttempts.ts index 0f97796aa4a75..3c50937599063 100644 --- a/apps/meteor/app/authentication/server/lib/logLoginAttempts.ts +++ b/apps/meteor/app/authentication/server/lib/logLoginAttempts.ts @@ -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, + }); }; diff --git a/apps/meteor/app/cloud/server/index.ts b/apps/meteor/app/cloud/server/index.ts index e7214295225b1..7bc7696d5b0dc 100644 --- a/apps/meteor/app/cloud/server/index.ts +++ b/apps/meteor/app/cloud/server/index.ts @@ -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 }); } }); }); diff --git a/apps/meteor/app/crowd/server/crowd.ts b/apps/meteor/app/crowd/server/crowd.ts index ac1467dedbe00..8e499b06f77c6 100644 --- a/apps/meteor/app/crowd/server/crowd.ts +++ b/apps/meteor/app/crowd/server/crowd.ts @@ -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); } }); diff --git a/apps/meteor/app/file-upload/server/methods/sendFileMessage.ts b/apps/meteor/app/file-upload/server/methods/sendFileMessage.ts index fd503b31644ce..fbad271ed0438 100644 --- a/apps/meteor/app/file-upload/server/methods/sendFileMessage.ts +++ b/apps/meteor/app/file-upload/server/methods/sendFileMessage.ts @@ -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)) { diff --git a/apps/meteor/app/file-upload/ufs/AmazonS3/server.ts b/apps/meteor/app/file-upload/ufs/AmazonS3/server.ts index 3cc3f04f9ccb3..9e00e4ea497f3 100644 --- a/apps/meteor/app/file-upload/ufs/AmazonS3/server.ts +++ b/apps/meteor/app/file-upload/ufs/AmazonS3/server.ts @@ -128,7 +128,7 @@ class AmazonS3Store extends UploadFS.Store { try { return s3.deleteObject(params).promise(); } catch (err: any) { - SystemLogger.error(err); + SystemLogger.error({ err }); } }; @@ -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'); diff --git a/apps/meteor/app/file-upload/ufs/GoogleStorage/server.ts b/apps/meteor/app/file-upload/ufs/GoogleStorage/server.ts index 2034ea2135706..e2b71ac8052d7 100644 --- a/apps/meteor/app/file-upload/ufs/GoogleStorage/server.ts +++ b/apps/meteor/app/file-upload/ufs/GoogleStorage/server.ts @@ -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 }); } }; diff --git a/apps/meteor/app/file-upload/ufs/Webdav/server.ts b/apps/meteor/app/file-upload/ufs/Webdav/server.ts index 69ab18a4ebb08..e5a8a62b5d059 100644 --- a/apps/meteor/app/file-upload/ufs/Webdav/server.ts +++ b/apps/meteor/app/file-upload/ufs/Webdav/server.ts @@ -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 }); } }; diff --git a/apps/meteor/app/importer/server/classes/converters/MessageConverter.ts b/apps/meteor/app/importer/server/classes/converters/MessageConverter.ts index 8fa9eaba04534..825090147be8a 100644 --- a/apps/meteor/app/importer/server/classes/converters/MessageConverter.ts +++ b/apps/meteor/app/importer/server/classes/converters/MessageConverter.ts @@ -41,9 +41,8 @@ export class MessageConverter extends RecordConverter { 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 }); } } } @@ -70,9 +69,8 @@ export class MessageConverter extends RecordConverter { 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 }); } } @@ -167,7 +165,7 @@ export class MessageConverter extends RecordConverter { } 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'); } diff --git a/apps/meteor/app/integrations/server/lib/triggerHandler.ts b/apps/meteor/app/integrations/server/lib/triggerHandler.ts index 0a29396ec2c32..abf3437f1bed9 100644 --- a/apps/meteor/app/integrations/server/lib/triggerHandler.ts +++ b/apps/meteor/app/integrations/server/lib/triggerHandler.ts @@ -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; } diff --git a/apps/meteor/app/settings/server/CachedSettings.ts b/apps/meteor/app/settings/server/CachedSettings.ts index 6a16a4c761313..3c46dd05a6806 100644 --- a/apps/meteor/app/settings/server/CachedSettings.ts +++ b/apps/meteor/app/settings/server/CachedSettings.ts @@ -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); } @@ -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); } @@ -134,7 +134,7 @@ export class CachedSettings */ public get(_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; } @@ -148,7 +148,7 @@ export class CachedSettings */ public getByRegexp(_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][]; diff --git a/apps/meteor/app/settings/server/SettingsRegistry.ts b/apps/meteor/app/settings/server/SettingsRegistry.ts index cb6f9da20ab97..3b93ca5c0bfb6 100644 --- a/apps/meteor/app/settings/server/SettingsRegistry.ts +++ b/apps/meteor/app/settings/server/SettingsRegistry.ts @@ -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`); } @@ -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); @@ -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; } diff --git a/apps/meteor/ee/app/livechat-enterprise/server/hooks/afterOnHold.ts b/apps/meteor/ee/app/livechat-enterprise/server/hooks/afterOnHold.ts index bb38b53773602..89a28af413420 100644 --- a/apps/meteor/ee/app/livechat-enterprise/server/hooks/afterOnHold.ts +++ b/apps/meteor/ee/app/livechat-enterprise/server/hooks/afterOnHold.ts @@ -18,7 +18,7 @@ const handleAfterOnHold = async (room: Pick): Promise('Livechat_auto_close_on_hold_chats_custom_message') || i18n.t('Closed_automatically_because_chat_was_onhold_for_seconds', { diff --git a/apps/meteor/ee/app/livechat-enterprise/server/hooks/afterOnHoldChatResumed.ts b/apps/meteor/ee/app/livechat-enterprise/server/hooks/afterOnHoldChatResumed.ts index 9ebdfcacb539a..e114fd89ec435 100644 --- a/apps/meteor/ee/app/livechat-enterprise/server/hooks/afterOnHoldChatResumed.ts +++ b/apps/meteor/ee/app/livechat-enterprise/server/hooks/afterOnHoldChatResumed.ts @@ -13,7 +13,7 @@ const handleAfterOnHoldChatResumed = async (room: IRoom): Promise => { 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; diff --git a/apps/meteor/ee/app/livechat-enterprise/server/hooks/checkAgentBeforeTakeInquiry.ts b/apps/meteor/ee/app/livechat-enterprise/server/hooks/checkAgentBeforeTakeInquiry.ts index a76cc7871f45b..349ad44652bf1 100644 --- a/apps/meteor/ee/app/livechat-enterprise/server/hooks/checkAgentBeforeTakeInquiry.ts +++ b/apps/meteor/ee/app/livechat-enterprise/server/hooks/checkAgentBeforeTakeInquiry.ts @@ -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; } diff --git a/apps/meteor/ee/app/livechat-enterprise/server/hooks/resumeOnHold.ts b/apps/meteor/ee/app/livechat-enterprise/server/hooks/resumeOnHold.ts index 85239c4fe1fc9..b35b9e8acce5f 100644 --- a/apps/meteor/ee/app/livechat-enterprise/server/hooks/resumeOnHold.ts +++ b/apps/meteor/ee/app/livechat-enterprise/server/hooks/resumeOnHold.ts @@ -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'); } @@ -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`); } @@ -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; } } diff --git a/apps/meteor/server/lib/ldap/Manager.ts b/apps/meteor/server/lib/ldap/Manager.ts index 19dd6a516e789..9b747c0f78fd9 100644 --- a/apps/meteor/server/lib/ldap/Manager.ts +++ b/apps/meteor/server/lib/ldap/Manager.ts @@ -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; @@ -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 }); } } diff --git a/apps/meteor/server/modules/streamer/streamer.module.ts b/apps/meteor/server/modules/streamer/streamer.module.ts index 01cdd6861600d..e55592fb2e907 100644 --- a/apps/meteor/server/modules/streamer/streamer.module.ts +++ b/apps/meteor/server/modules/streamer/streamer.module.ts @@ -78,7 +78,7 @@ export abstract class Streamer 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) { diff --git a/apps/meteor/server/services/omnichannel-analytics/service.ts b/apps/meteor/server/services/omnichannel-analytics/service.ts index 9ad567feaa188..24ce8ded79f2a 100644 --- a/apps/meteor/server/services/omnichannel-analytics/service.ts +++ b/apps/meteor/server/services/omnichannel-analytics/service.ts @@ -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; } @@ -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; } @@ -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; } diff --git a/apps/meteor/server/services/omnichannel-integrations/providers/twilio.ts b/apps/meteor/server/services/omnichannel-integrations/providers/twilio.ts index 26b6dbaea1cf9..fe4f5e30241b0 100644 --- a/apps/meteor/server/services/omnichannel-integrations/providers/twilio.ts +++ b/apps/meteor/server/services/omnichannel-integrations/providers/twilio.ts @@ -78,7 +78,7 @@ export class Twilio implements ISMSProvider { } if (isNaN(numMedia)) { - SystemLogger.error(`Error parsing NumMedia ${data.NumMedia}`); + SystemLogger.error({ msg: 'Error parsing NumMedia', numMedia: data.NumMedia }); return returnData; } @@ -114,7 +114,7 @@ export class Twilio implements ISMSProvider { return twilio(sid, token); } catch (error) { await notifyAgent(userId, rid, i18n.t('SMS_Twilio_InvalidCredentials')); - SystemLogger.error(`(Twilio) -> ${error}`); + SystemLogger.error({ msg: '(Twilio) ->', err: error }); } } @@ -157,7 +157,7 @@ export class Twilio implements ISMSProvider { if (reason) { await notifyAgent(userId, rid, reason); - SystemLogger.error(`(Twilio) -> ${reason}`); + SystemLogger.error({ msg: '(Twilio) ->', reason }); return ''; } @@ -219,7 +219,7 @@ export class Twilio implements ISMSProvider { if (result.errorCode) { await notifyAgent(userId, rid, result.errorMessage); - SystemLogger.error(`(Twilio) -> ${result.errorCode}`); + SystemLogger.error({ msg: '(Twilio) ->', errorCode: result.errorCode }); } return { diff --git a/apps/meteor/server/services/omnichannel/queue.ts b/apps/meteor/server/services/omnichannel/queue.ts index 89acb5434702f..d522c78d7daaa 100644 --- a/apps/meteor/server/services/omnichannel/queue.ts +++ b/apps/meteor/server/services/omnichannel/queue.ts @@ -46,7 +46,7 @@ export class OmnichannelQueue implements IOmnichannelQueue { } const activeQueues = await this.getActiveQueues(); - queueLogger.debug(`Active queues: ${activeQueues.length}`); + queueLogger.debug({ msg: 'Active queues', count: activeQueues.length }); this.running = true; queueLogger.info('Service started'); @@ -118,22 +118,22 @@ export class OmnichannelQueue implements IOmnichannelQueue { } private async checkQueue(queue: string | null) { - queueLogger.debug(`Processing items for queue ${queue || 'Public'}`); + queueLogger.debug({ msg: 'Processing items for queue', queue: queue || 'Public' }); try { const nextInquiry = await LivechatInquiry.findNextAndLock(getOmniChatSortQuery(getInquirySortMechanismSetting()), queue); if (!nextInquiry) { - queueLogger.debug(`No more items for queue ${queue || 'Public'}`); + queueLogger.debug({ msg: 'No more items for queue', queue: queue || 'Public' }); return; } const result = await this.processWaitingQueue(queue, nextInquiry as InquiryWithAgentInfo); if (!result) { - queueLogger.debug(`Inquiry ${nextInquiry._id} not taken. Unlocking and re-queueing`); + queueLogger.debug({ msg: 'Inquiry not taken. Unlocking and re-queueing', inquiry: nextInquiry._id }); return await LivechatInquiry.unlock(nextInquiry._id); } - queueLogger.debug(`Inquiry ${nextInquiry._id} taken successfully. Unlocking`); + queueLogger.debug({ msg: 'Inquiry taken successfully. Unlocking', inquiry: nextInquiry._id }); await LivechatInquiry.unlock(nextInquiry._id); queueLogger.debug({ msg: 'Inquiry processed', @@ -264,7 +264,7 @@ export class OmnichannelQueue implements IOmnichannelQueue { _id: rid, servedBy: { _id: agentId }, } = room; - queueLogger.debug(`Inquiry ${inquiry._id} taken successfully by agent ${agentId}. Notifying`); + queueLogger.debug({ msg: 'Inquiry taken successfully by agent. Notifying', inquiry: inquiry._id, agentId }); setTimeout(() => { void dispatchAgentDelegated(rid, agentId); }, 1000); diff --git a/apps/meteor/server/startup/migrations/v317.ts b/apps/meteor/server/startup/migrations/v317.ts index 02867fcdb5cc7..383f2a47adb0b 100644 --- a/apps/meteor/server/startup/migrations/v317.ts +++ b/apps/meteor/server/startup/migrations/v317.ts @@ -70,7 +70,7 @@ addMigration({ return; } - SystemLogger.warn(`The default value of the setting ${key} has changed to ${newValue}. Please review your settings.`); + SystemLogger.warn({ msg: 'The default value of the setting has changed. Please review your settings.', key, newValue }); return Settings.updateOne({ _id: key }, { $set: { value: newValue } }); }) @@ -91,9 +91,11 @@ addMigration({ return; } - SystemLogger.warn( - `The default value of the custom setting ${_id} has changed to ${newDefaultButtonColor}. Please review your settings.`, - ); + SystemLogger.warn({ + msg: 'The default value of the custom setting has changed. Please review your settings.', + _id, + newValue: newDefaultButtonColor, + }); return Settings.updateOne({ _id }, { $set: { value: newDefaultButtonColor } }); }) @@ -105,9 +107,11 @@ addMigration({ return; } - SystemLogger.warn( - `The default value of the custom setting ${_id} has changed to ${newDefaultButtonLabelColor}. Please review your settings.`, - ); + SystemLogger.warn({ + msg: 'The default value of the custom setting has changed. Please review your settings.', + _id, + newValue: newDefaultButtonLabelColor, + }); return Settings.updateOne({ _id }, { $set: { value: newDefaultButtonLabelColor } }); }) diff --git a/apps/meteor/tests/unit/server/services/omnichannel/queue.tests.ts b/apps/meteor/tests/unit/server/services/omnichannel/queue.tests.ts index 4d498a204307f..1580620ae509f 100644 --- a/apps/meteor/tests/unit/server/services/omnichannel/queue.tests.ts +++ b/apps/meteor/tests/unit/server/services/omnichannel/queue.tests.ts @@ -384,7 +384,6 @@ describe('Omnichannel Queue processor', () => { await queue.execute(); expect(queue.getActiveQueues.calledOnce).to.be.true; - expect(queueLogger.debug.calledWith('Processing items for queue Public')).to.be.true; }); }); describe('start', () => { diff --git a/ee/packages/federation-matrix/src/setup.ts b/ee/packages/federation-matrix/src/setup.ts index f307d9c1e5327..ccfffb3ad0da0 100644 --- a/ee/packages/federation-matrix/src/setup.ts +++ b/ee/packages/federation-matrix/src/setup.ts @@ -14,7 +14,7 @@ function validateDomain(domain: string): boolean { } if (value.toLowerCase() !== value) { - logger.error(`The Federation domain "${value}" cannot have uppercase letters`); + logger.error({ msg: 'The Federation domain cannot have uppercase letters', domain: value }); return false; } @@ -25,7 +25,7 @@ function validateDomain(domain: string): boolean { throw new Error(); } } catch { - logger.error(`The configured Federation domain "${value}" is not valid`); + logger.error({ msg: 'The configured Federation domain is not valid', domain: value }); return false; } diff --git a/ee/packages/license/src/license.ts b/ee/packages/license/src/license.ts index 3e94af592066a..0e92af730b1cf 100644 --- a/ee/packages/license/src/license.ts +++ b/ee/packages/license/src/license.ts @@ -355,10 +355,8 @@ export abstract class LicenseManager extends Emitter { this.emit('installed'); return true; - } catch (e) { - logger.error('Invalid license'); - - logger.error({ msg: 'Invalid raw license', encryptedLicense, e }); + } catch (err) { + logger.error({ msg: 'Invalid raw license', encryptedLicense, err }); throw new InvalidLicenseError(); } diff --git a/ee/packages/omnichannel-services/src/QueueWorker.ts b/ee/packages/omnichannel-services/src/QueueWorker.ts index 3e18e4fea4b7a..69855f14071c2 100644 --- a/ee/packages/omnichannel-services/src/QueueWorker.ts +++ b/ee/packages/omnichannel-services/src/QueueWorker.ts @@ -46,7 +46,7 @@ export class QueueWorker extends ServiceClass implements IQueueWorkerService { await this.createIndexes(); this.registerWorkers(); } catch (e) { - this.logger.fatal(e, 'Fatal error occurred when registering workers'); + this.logger.fatal({ msg: 'Fatal error occurred when registering workers', err: e }); process.exit(1); } } @@ -75,24 +75,24 @@ export class QueueWorker extends ServiceClass implements IQueueWorkerService { } private async workerCallback(queueItem: Work<{ to: string; data: any }>): Promise { - this.logger.info(`Processing queue item ${queueItem._id} for work`); - this.logger.info(`Queue item is trying to call ${queueItem.message.to}`); + this.logger.info({ msg: 'Processing queue item for work', queueItemId: queueItem._id }); + this.logger.info({ msg: 'Queue item is trying to call', to: queueItem.message.to }); try { await api.call(queueItem.message.to, [queueItem.message]); - this.logger.info(`Queue item ${queueItem._id} completed`); + this.logger.info({ msg: 'Queue item completed', queueItemId: queueItem._id }); return 'Completed' as const; } catch (err: unknown) { const e = err as Error; - this.logger.error(`Queue item ${queueItem._id} errored: ${e.message}`); + this.logger.error({ msg: 'Queue item errored', queueItemId: queueItem._id, err: e }); queueItem.releasedReason = e.message; // Let's only retry for X times when the error is "service not found" // For any other error, we'll just reject the item if ((queueItem.retryCount || 0) < this.retryCount && this.isRetryableError(e.message)) { - this.logger.info(`Queue item ${queueItem._id} will be retried in 10 seconds`); + this.logger.info({ msg: 'Queue item will be retried', queueItemId: queueItem._id, retry: this.retryDelay }); queueItem.nextReceivableTime = new Date(Date.now() + this.retryDelay); return 'Retry' as const; } - this.logger.info(`Queue item ${queueItem._id} will be rejected`); + this.logger.info({ msg: 'Queue item will be rejected', queueItemId: queueItem._id }); return 'Rejected' as const; } } @@ -119,7 +119,7 @@ export class QueueWorker extends ServiceClass implements IQueueWorkerService { // `to` is a service name that will be called, including namespace + action // This is a "generic" job that allows you to call any service async queueWork>(queue: Actions, to: string, data: T): Promise { - this.logger.info(`Queueing work for ${to}`); + this.logger.info({ msg: 'Queueing work for', to }); if (!this.matchServiceCall(to)) { // We don't want to queue calls to invalid service names throw new Error(`Invalid service name ${to}`); diff --git a/packages/apps-engine/src/server/runtime/deno/AppsEngineDenoRuntime.ts b/packages/apps-engine/src/server/runtime/deno/AppsEngineDenoRuntime.ts index 8b4eb385a88f8..d445eeac0ccd8 100644 --- a/packages/apps-engine/src/server/runtime/deno/AppsEngineDenoRuntime.ts +++ b/packages/apps-engine/src/server/runtime/deno/AppsEngineDenoRuntime.ts @@ -287,7 +287,7 @@ export class DenoRuntimeSubprocessController extends EventEmitter implements IRu this.debug('Restarting app subprocess'); const logger = new AppConsole('runtime:restart'); - logger.info('Starting restart procedure for app subprocess...', this.livenessManager.getRuntimeData()); + logger.info({ msg: 'Starting restart procedure for app subprocess...', runtimeData: this.livenessManager.getRuntimeData() }); this.state = 'restarting'; @@ -297,13 +297,13 @@ export class DenoRuntimeSubprocessController extends EventEmitter implements IRu const hasKilled = await this.killProcess(); if (hasKilled) { - logger.debug('Process successfully terminated', { pid }); + logger.debug({ msg: 'Process successfully terminated', pid }); } else { - logger.warn('Could not terminate process. Maybe it was already dead?', { pid }); + logger.warn({ msg: 'Could not terminate process. Maybe it was already dead?', pid }); } await this.setupApp(); - logger.info('New subprocess successfully spawned', { pid: this.deno.pid }); + logger.info({ msg: 'New subprocess successfully spawned', pid: this.deno.pid }); // setupApp() changes the state to 'ready' - we'll need to workaround that for now this.state = 'restarting'; @@ -319,7 +319,7 @@ export class DenoRuntimeSubprocessController extends EventEmitter implements IRu logger.info('Successfully restarted app subprocess'); } catch (e) { - logger.error("Failed to restart app's subprocess", { error: e.message || e }); + logger.error({ msg: "Failed to restart app's subprocess", err: e }); throw e; } finally { await this.logStorage.storeEntries(AppConsole.toStorageEntry(this.getAppId(), logger));