refactor(server): reduce server logs (#11931)

close CLOUD-201
This commit is contained in:
fengmk2
2025-04-23 11:41:47 +00:00
parent ddb739fa13
commit ff133d1267
18 changed files with 70 additions and 46 deletions
@@ -32,7 +32,7 @@ export class DocRpcController {
if (!doc) {
throw new NotFound('Doc not found');
}
this.logger.log(
this.logger.debug(
`get doc ${docId} from workspace ${workspaceId}, size: ${doc.bin.length}`
);
res.setHeader('x-doc-timestamp', doc.timestamp.toString());
@@ -59,7 +59,7 @@ export class DocRpcController {
if (!diff) {
throw new NotFound('Doc not found');
}
this.logger.log(
this.logger.debug(
`get doc diff ${docId} from workspace ${workspaceId}, missing size: ${diff.missing.length}, old state size: ${stateVector?.length}, new state size: ${diff.state.length}`
);
res.setHeader('x-doc-timestamp', diff.timestamp.toString());
@@ -86,7 +86,7 @@ export class DocRpcController {
if (!content) {
throw new NotFound('Doc not found');
}
this.logger.log(`get doc content ${docId} from workspace ${workspaceId}`);
this.logger.debug(`get doc content ${docId} from workspace ${workspaceId}`);
return content;
}
@@ -98,7 +98,7 @@ export class DocRpcController {
if (!content) {
throw new NotFound('Workspace not found');
}
this.logger.log(`get workspace content ${workspaceId}`);
this.logger.debug(`get workspace content ${workspaceId}`);
return content;
}
}
@@ -103,7 +103,7 @@ export class MailSender {
}
metrics.mail.counter('accepted_total').add(1, { name });
this.logger.log(`Mail [${name}] sent successfully.`);
this.logger.debug(`Mail [${name}] sent successfully.`);
if (this.usingTestAccount) {
this.logger.debug(
` ⚙️ Mail preview url: ${getTestMessageUrl(result)}`
@@ -78,7 +78,7 @@ export class NotificationService {
},
},
});
this.logger.log(`Mention email sent to user ${receiver.id}`);
this.logger.debug(`Mention email sent to user ${receiver.id}`);
}
async createInvitation(input: InvitationNotificationCreate) {
@@ -123,7 +123,7 @@ export class NotificationService {
url: inviteUrl,
},
});
this.logger.log(
this.logger.debug(
`Invitation email sent to user ${receiver.id} for workspace ${input.body.workspaceId}`
);
}
@@ -179,7 +179,7 @@ export class NotificationService {
),
},
});
this.logger.log(
this.logger.debug(
`Invitation accepted email sent to user ${inviter.id} for workspace ${workspaceId}`
);
}
@@ -244,7 +244,7 @@ export class NotificationService {
),
},
});
this.logger.log(
this.logger.debug(
`Invitation review request email sent to user ${reviewer.id} for workspace ${workspaceId}`
);
}
@@ -283,7 +283,7 @@ export class NotificationService {
url: this.url.link(`/workspace/${workspaceId}`),
},
});
this.logger.log(
this.logger.debug(
`Invitation review approved email sent to user ${receiver.id} for workspace ${workspaceId}`
);
}
@@ -321,7 +321,7 @@ export class NotificationService {
},
},
});
this.logger.log(
this.logger.debug(
`Invitation review declined email sent to user ${receiver.id} for workspace ${workspaceId}`
);
}
@@ -36,7 +36,7 @@ export class DocAccessController extends AccessController<'doc'> {
const allow = permissions[action] || false;
if (!allow) {
this.logger.log('Doc access check failed', {
this.logger.debug('Doc access check failed', {
action,
resource,
role,
@@ -40,7 +40,7 @@ export class WorkspaceAccessController extends AccessController<'ws'> {
const allow = permissions[action] || false;
if (!allow) {
this.logger.log('Workspace access check failed', {
this.logger.debug('Workspace access check failed', {
action,
resource,
role,
@@ -152,13 +152,15 @@ export class SpaceSyncGateway
handleConnection() {
this.connectionCount++;
this.logger.log(`New connection, total: ${this.connectionCount}`);
this.logger.debug(`New connection, total: ${this.connectionCount}`);
metrics.socketio.gauge('connections').record(this.connectionCount);
}
handleDisconnect() {
this.connectionCount--;
this.logger.log(`Connection disconnected, total: ${this.connectionCount}`);
this.logger.debug(
`Connection disconnected, total: ${this.connectionCount}`
);
metrics.socketio.gauge('connections').record(this.connectionCount);
}
@@ -536,7 +536,7 @@ export class DocResolver {
@Args('input') input: UpdateDocDefaultRoleInput
) {
if (input.role === DocRole.Owner) {
this.logger.log(
this.logger.debug(
`Doc default role can not be owner (${JSON.stringify(input)})`
);
throw new DocDefaultRoleCanNotBeOwner();
@@ -559,7 +559,7 @@ export class DocResolver {
await this.ac.user(user.id).doc(input).assert('Doc.Users.Manage');
} catch (error) {
if (error instanceof DocActionDenied) {
this.logger.log(
this.logger.debug(
`User does not have permission to update page default role (${JSON.stringify(
{
...pairs,