fix: logs meta

This commit is contained in:
Karol Sójko 2023-12-07 13:39:30 +01:00
parent a2b1323568
commit 8ac84c59af
No known key found for this signature in database
GPG key ID: C2F813669419D05F
4 changed files with 21 additions and 16 deletions

View file

@ -19,7 +19,7 @@ export class AccountDeletionRequestedEventHandler implements DomainEventHandlerI
async handle(event: AccountDeletionRequestedEvent): Promise<void> { async handle(event: AccountDeletionRequestedEvent): Promise<void> {
const userUuidOrError = Uuid.create(event.payload.userUuid) const userUuidOrError = Uuid.create(event.payload.userUuid)
if (userUuidOrError.isFailed()) { if (userUuidOrError.isFailed()) {
this.logger.warn(`Could not find user with uuid: ${event.payload.userUuid}`) this.logger.warn('Could not find user.', { userId: event.payload.userUuid })
return return
} }
@ -28,7 +28,7 @@ export class AccountDeletionRequestedEventHandler implements DomainEventHandlerI
const user = await this.userRepository.findOneByUuid(userUuid) const user = await this.userRepository.findOneByUuid(userUuid)
if (user === null) { if (user === null) {
this.logger.warn(`Could not find user with uuid: ${userUuid.value}`) this.logger.warn('Could not find user.', { userId: userUuid.value })
return return
} }
@ -37,7 +37,9 @@ export class AccountDeletionRequestedEventHandler implements DomainEventHandlerI
await this.userRepository.remove(user) await this.userRepository.remove(user)
this.logger.info(`Finished account cleanup for user: ${userUuid.value}`) this.logger.info('Finished account cleanup.', {
userId: userUuid.value,
})
} }
private async removeSessions(userUuid: string): Promise<void> { private async removeSessions(userUuid: string): Promise<void> {

View file

@ -22,7 +22,7 @@ export class WebSocketsClientService implements ClientServiceInterface {
(await user.roles).map((role) => role.name), (await user.roles).map((role) => role.name),
) )
this.logger.info(`[WebSockets] Requesting message ${event.type} to user ${user.uuid}`) this.logger.debug(`[WebSockets] Requesting message ${event.type} to user ${user.uuid}`)
await this.domainEventPublisher.publish( await this.domainEventPublisher.publish(
this.domainEventFactory.createWebSocketMessageRequestedEvent({ this.domainEventFactory.createWebSocketMessageRequestedEvent({

View file

@ -12,7 +12,7 @@ export class AccountDeletionRequestedEventHandler implements DomainEventHandlerI
async handle(event: AccountDeletionRequestedEvent): Promise<void> { async handle(event: AccountDeletionRequestedEvent): Promise<void> {
const userUuidOrError = Uuid.create(event.payload.userUuid) const userUuidOrError = Uuid.create(event.payload.userUuid)
if (userUuidOrError.isFailed()) { if (userUuidOrError.isFailed()) {
this.logger.warn(`Failed account cleanup: ${userUuidOrError.getError()}`) this.logger.warn(`Failed account cleanup: ${userUuidOrError.getError()}`, { userId: event.payload.userUuid })
return return
} }
@ -20,6 +20,6 @@ export class AccountDeletionRequestedEventHandler implements DomainEventHandlerI
await this.revisionRepository.removeByUserUuid(userUuid) await this.revisionRepository.removeByUserUuid(userUuid)
this.logger.info(`Finished account cleanup for user: ${event.payload.userUuid}`) this.logger.info('Finished account cleanup.', { userId: event.payload.userUuid })
} }
} }

View file

@ -17,7 +17,10 @@ export class AccountDeletionRequestedEventHandler implements DomainEventHandlerI
async handle(event: AccountDeletionRequestedEvent): Promise<void> { async handle(event: AccountDeletionRequestedEvent): Promise<void> {
const userUuidOrError = Uuid.create(event.payload.userUuid) const userUuidOrError = Uuid.create(event.payload.userUuid)
if (userUuidOrError.isFailed()) { if (userUuidOrError.isFailed()) {
this.logger.error(`AccountDeletionRequestedEventHandler failed: ${userUuidOrError.getError()}`) this.logger.error(userUuidOrError.getError(), {
userId: event.payload.userUuid,
codeTag: 'AccountDeletionRequestedEventHandler',
})
return return
} }
@ -30,9 +33,9 @@ export class AccountDeletionRequestedEventHandler implements DomainEventHandlerI
allowSurviving: true, allowSurviving: true,
}) })
if (deletingVaultsResult.isFailed()) { if (deletingVaultsResult.isFailed()) {
this.logger.error( this.logger.error(`Failed to delete shared vaults: ${deletingVaultsResult.getError()}`, {
`Failed to delete shared vaults for user: ${event.payload.userUuid}: ${deletingVaultsResult.getError()}`, userId: event.payload.userUuid,
) })
} }
const deletedSharedVaultUuids = Array.from(deletingVaultsResult.getValue().keys()) const deletedSharedVaultUuids = Array.from(deletingVaultsResult.getValue().keys())
@ -49,13 +52,13 @@ export class AccountDeletionRequestedEventHandler implements DomainEventHandlerI
userUuid: event.payload.userUuid, userUuid: event.payload.userUuid,
}) })
if (deletingUserFromOtherVaultsResult.isFailed()) { if (deletingUserFromOtherVaultsResult.isFailed()) {
this.logger.error( this.logger.error(`Failed to remove user from shared vaults: ${deletingUserFromOtherVaultsResult.getError()}`, {
`Failed to remove user: ${ userId: event.payload.userUuid,
event.payload.userUuid })
} from shared vaults: ${deletingUserFromOtherVaultsResult.getError()}`,
)
} }
this.logger.info(`Finished account cleanup for user: ${event.payload.userUuid}`) this.logger.info('Finished account cleanup', {
userId: event.payload.userUuid,
})
} }
} }