From 0eb5a20bbb8a925425a2fa64eb2ed81d2ea3d1fc Mon Sep 17 00:00:00 2001 From: gustrb Date: Mon, 21 Oct 2024 16:54:28 -0300 Subject: [PATCH] chore: improve logging --- .../app/cloud/server/functions/getWorkspaceAccessToken.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/apps/meteor/app/cloud/server/functions/getWorkspaceAccessToken.ts b/apps/meteor/app/cloud/server/functions/getWorkspaceAccessToken.ts index 3a9d06fc7f71..a85b845382d0 100644 --- a/apps/meteor/app/cloud/server/functions/getWorkspaceAccessToken.ts +++ b/apps/meteor/app/cloud/server/functions/getWorkspaceAccessToken.ts @@ -1,6 +1,7 @@ import type { IWorkspaceCredentials } from '@rocket.chat/core-typings'; import { WorkspaceCredentials } from '@rocket.chat/models'; +import { SystemLogger } from '../../../../server/lib/logger/system'; import { workspaceScopes } from '../oauthScopes'; import { getWorkspaceAccessTokenWithScope } from './getWorkspaceAccessTokenWithScope'; import { retrieveRegistrationStatus } from './retrieveRegistrationStatus'; @@ -31,9 +32,14 @@ export async function getWorkspaceAccessToken(forceNew = false, scope = '', save const workspaceCredentials = await WorkspaceCredentials.getCredentialByScope(scopes); if (workspaceCredentials && !hasWorkspaceAccessTokenExpired(workspaceCredentials) && !forceNew) { + SystemLogger.debug( + `Workspace credentials cache hit using scopes: ${scopes}. Avoiding generating a new access token from cloud services.`, + ); return workspaceCredentials.accessToken; } + SystemLogger.debug(`Workspace credentials cache miss using scopes: ${scopes}, fetching new access token from cloud services.`); + const accessToken = await getWorkspaceAccessTokenWithScope(scope, throwOnError); if (save) {