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
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const notifyFailedLogin = async (ipOrUsername: string, blockedUntil: Date, faile
// to avoid issues when "fname" is presented in the UI, check if the name matches it as well
const room = await Rooms.findOneByNameOrFname(channelToNotify);
if (!room) {
logger.error("Cannot notify failed logins: channel provided doesn't exists");
logger.error({ msg: 'Cannot notify failed logins: channel provided does not exist', channelToNotify });
return;
}

Expand Down
2 changes: 1 addition & 1 deletion apps/meteor/app/authentication/server/startup/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ Accounts.insertUserDoc = async function (options, user) {
if (!options.skipAppsEngineEvent) {
// `post` triggered events don't need to wait for the promise to resolve
Apps.self?.triggerEvent(AppEvents.IPostUserCreated, { user, performedBy: await safeGetMeteorUser() }).catch((e) => {
Apps.self?.getRocketChatLogger().error('Error while executing post user created event:', e);
Apps.self?.getRocketChatLogger().error({ msg: 'Error while executing post user created event', err: e });
});
}

Expand Down
4 changes: 2 additions & 2 deletions apps/meteor/app/custom-oauth/server/custom_oauth_server.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const BeforeUpdateOrCreateUserFromExternalService = [];

export class CustomOAuth {
constructor(name, options) {
logger.debug('Init CustomOAuth', name, options);
logger.debug({ msg: 'Init CustomOAuth', name, options });

this.name = name;
if (!Match.test(this.name, String)) {
Expand Down Expand Up @@ -307,7 +307,7 @@ export class CustomOAuth {
const value = fromTemplate(this.avatarField, data);

if (!value) {
logger.debug(`Avatar field "${this.avatarField}" not found in data`, data);
logger.debug({ msg: 'Avatar field not found in data', avatarField: this.avatarField, data });
}
return value;
} catch (error) {
Expand Down
2 changes: 1 addition & 1 deletion apps/meteor/app/irc/server/irc-bridge/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ class Bridge {
// Get the command
const item = this.queue.dequeue();

this.logQueue(`Processing "${item.command}" command from "${item.from}"`);
this.logQueue({ msg: 'Processing command from source', command: item.command, from: item.from });

// Handle the command accordingly
try {
Expand Down
23 changes: 16 additions & 7 deletions apps/meteor/app/irc/server/servers/RFC2813/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ class RFC2813 {
this.socket.on('data', this.onReceiveFromPeer.bind(this));

this.socket.on('connect', this.onConnect.bind(this));
this.socket.on('error', (err) => logger.error(err));
this.socket.on('timeout', () => this.log('Timeout'));
this.socket.on('close', () => this.log('Connection Closed'));
this.socket.on('error', (err) => logger.error({ msg: 'Socket error', err }));
this.socket.on('timeout', () => this.log({ msg: 'Timeout' }));
this.socket.on('close', () => this.log({ msg: 'Connection Closed' }));
// Setup local
this.on('onReceiveFromLocal', this.onReceiveFromLocal.bind(this));
}
Expand All @@ -51,14 +51,23 @@ class RFC2813 {
*/
log(message) {
// TODO logger: debug?
if (typeof message === 'string') {
logger.info({ msg: message });
return;
}

logger.info(message);
}

/**
* Connect
*/
register() {
this.log(`Connecting to @${this.config.server.host}:${this.config.server.port}`);
this.log({
msg: 'Connecting to IRC server',
host: this.config.server.host,
port: this.config.server.port,
});

if (!this.socket) {
this.setupSocket();
Expand Down Expand Up @@ -114,7 +123,7 @@ class RFC2813 {
buffer += ` :${command.trailer}`;
}

this.log(`Sending Command: ${buffer}`);
this.log({ msg: 'Sending Command', buffer });

return this.socket.write(`${buffer}\r\n`);
}
Expand Down Expand Up @@ -148,7 +157,7 @@ class RFC2813 {
const parsedMessage = parseMessage(line);

if (peerCommandHandlers[parsedMessage.command]) {
this.log(`Handling peer message: ${line}`);
this.log({ msg: 'Handling peer message', line });

const command = peerCommandHandlers[parsedMessage.command].call(this, parsedMessage);

Expand All @@ -172,7 +181,7 @@ class RFC2813 {
*/
onReceiveFromLocal(command, parameters) {
if (localCommandHandlers[command]) {
this.log(`Handling local command: ${command}`);
this.log({ msg: 'Handling local command', command });

localCommandHandlers[command].call(this, parameters, this);
} else {
Expand Down
10 changes: 5 additions & 5 deletions apps/meteor/app/slackbridge/server/RocketAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export default class RocketAdapter {
continue;
}

rocketLogger.debug('onRocketMessageDelete', rocketMessageDeleted);
rocketLogger.debug({ msg: 'onRocketMessageDelete', rocketMessageDeleted });
await slack.postDeleteMessage(rocketMessageDeleted);
} catch (err) {
rocketLogger.error({ msg: 'Unhandled error onMessageDelete', err });
Expand Down Expand Up @@ -137,7 +137,7 @@ export default class RocketAdapter {
// This is on a channel that the rocket bot is not subscribed
continue;
}
rocketLogger.debug('onRocketMessage', rocketMessage);
rocketLogger.debug({ msg: 'onRocketMessage', rocketMessage });

if (rocketMessage.editedAt) {
// This is an Edit Event
Expand Down Expand Up @@ -260,7 +260,7 @@ export default class RocketAdapter {
}

async addChannel(slackChannelID, hasRetried = false) {
rocketLogger.debug('Adding Rocket.Chat channel from Slack', slackChannelID);
rocketLogger.debug({ msg: 'Adding Rocket.Chat channel from Slack', slackChannelID });
let addedRoom;

for await (const slack of this.slackAdapters) {
Expand Down Expand Up @@ -296,12 +296,12 @@ export default class RocketAdapter {
slackChannel.rocketId = rocketChannel.rid;
} catch (e) {
if (!hasRetried) {
rocketLogger.debug('Error adding channel from Slack. Will retry in 1s.', e.message);
rocketLogger.debug({ msg: 'Error adding channel from Slack. Will retry in 1s.', err: e });
// If first time trying to create channel fails, could be because of multiple messages received at the same time. Try again once after 1s.
await sleep(1000);
return (await this.findChannel(slackChannelID)) || this.addChannel(slackChannelID, true);
}
rocketLogger.error(e);
rocketLogger.error({ msg: 'Error adding channel from Slack', err: e });
}

const roomUpdate = {
Expand Down
2 changes: 1 addition & 1 deletion apps/meteor/client/views/room/body/RoomBody.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ const RoomBody = (): ReactElement => {
</MessageListErrorBoundary>
</div>
</div>
<RoomComposer>
<RoomComposer aria-label={t('Room_composer')}>
<ComposerContainer
subscription={subscription}
onResize={handleComposerResize}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ const ThreadChat = ({ mainMessage }: ThreadChatProps) => {
<ThreadMessageList mainMessage={mainMessage} />
</MessageListErrorBoundary>

<RoomComposer>
<RoomComposer aria-label={t('Thread_composer')}>
<ComposerContainer
tmid={mainMessage._id}
subscription={subscription}
Expand Down
16 changes: 13 additions & 3 deletions apps/meteor/ee/server/apps/communication/rest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,11 @@ export class AppsRestApi {
const success = await manager.changeStatus(info.id, AppStatus.MANUALLY_ENABLED);
info.status = await success.getStatus();
} catch (error) {
orchestrator.getRocketChatLogger().warn(`App "${info.id}" was installed but could not be enabled: `, error);
orchestrator.getRocketChatLogger().warn({
msg: 'App was installed but could not be enabled',
appId: info.id,
err: error,
});
}

void orchestrator.getNotifier().appAdded(info.id);
Expand Down Expand Up @@ -512,7 +516,10 @@ export class AppsRestApi {

return API.v1.success({ result });
} catch (e: any) {
orchestrator.getRocketChatLogger().error(`Error triggering external components' events ${e.response.data}`);
orchestrator.getRocketChatLogger().error({
msg: "Error triggering external components' events",
err: e,
});
return API.v1.internalError();
}
},
Expand All @@ -534,7 +541,10 @@ export class AppsRestApi {
try {
const request = await orchestrator.getMarketplaceClient().fetch(`v1/bundles/${this.urlParams.id}/apps`, { headers });
if (request.status !== 200) {
orchestrator.getRocketChatLogger().error("Error getting the Bundle's Apps from the Marketplace:", await request.json());
orchestrator.getRocketChatLogger().error({
msg: "Error getting the Bundle's Apps from the Marketplace",
response: await request.json(),
});
return API.v1.failure();
}
result = await request.json();
Expand Down
45 changes: 35 additions & 10 deletions apps/meteor/ee/server/apps/orchestrator.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,15 +186,22 @@ export class AppServerOrchestrator {

await this.getManager().loadOne(app.getID(), true);
} catch (error) {
this._rocketchatLogger.warn(`App "${app.getInfo().name}" could not be enabled: `, error.message);
this._rocketchatLogger.warn({
msg: 'App could not be enabled',
appName: app.getInfo().name,
err: error,
});
}
}

await this.getBridges().getSchedulerBridge().startScheduler();

const appCount = (await this.getManager().get({ enabled: true })).length;

this._rocketchatLogger.info(`Loaded the Apps Framework and loaded a total of ${appCount} Apps!`);
this._rocketchatLogger.info({
msg: 'Loaded the Apps Framework and apps',
appCount,
});
}

async migratePrivateApps() {
Expand Down Expand Up @@ -234,12 +241,19 @@ export class AppServerOrchestrator {

if (hadPreTargetVersion && majorVersion >= targetVersion) {
upgradeToV7Date = new Date(stat.installedAt);
this._rocketchatLogger.info(`Found upgrade to v${targetVersion} date: ${upgradeToV7Date.toISOString()}`);
this._rocketchatLogger.info({
msg: 'Found upgrade to target version date',
targetVersion,
upgradeToDate: upgradeToV7Date.toISOString(),
});
break;
}
}
} catch (error) {
this._rocketchatLogger.error('Error checking statistics for version history:', error.message);
} catch (err) {
this._rocketchatLogger.error({
msg: 'Error checking statistics for version history',
err,
});
}

return upgradeToV7Date;
Expand Down Expand Up @@ -300,11 +314,17 @@ export class AppServerOrchestrator {

try {
await Promise.all(disablePromises);
this._rocketchatLogger.info(
`${installationSource} apps processing complete - kept ${grandfathered.length + toKeep.length}, disabled ${toDisable.length}`,
);
this._rocketchatLogger.info({
msg: 'Apps processing complete',
installationSource,
keptCount: grandfathered.length + toKeep.length,
disabledCount: toDisable.length,
});
} catch (error) {
this._rocketchatLogger.error('Error disabling apps:', error.message);
this._rocketchatLogger.error({
msg: 'Error disabling apps',
err: error,
});
}
}

Expand All @@ -318,7 +338,12 @@ export class AppServerOrchestrator {
return this._manager
.unload()
.then(() => this._rocketchatLogger.info('Unloaded the Apps Framework.'))
.catch((err) => this._rocketchatLogger.error({ msg: 'Failed to unload the Apps Framework!', err }));
.catch((err) =>
this._rocketchatLogger.error({
msg: 'Failed to unload the Apps Framework!',
err,
}),
);
}

async updateAppsMarketplaceInfo(apps = []) {
Expand Down
Loading
Loading