From 1575c5a46d5898959822a28c4981c3312ce9e315 Mon Sep 17 00:00:00 2001 From: Gsk54 Date: Mon, 26 Dec 2022 15:23:53 +0100 Subject: [PATCH] fix logging --- src/modules/users/domain/usecases/create-user.usecase.ts | 6 +++++- src/modules/users/domain/usecases/delete-user.usecase.ts | 4 ++-- src/modules/users/domain/usecases/update-user.usecase.ts | 2 +- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/modules/users/domain/usecases/create-user.usecase.ts b/src/modules/users/domain/usecases/create-user.usecase.ts index d1ef4e4..1947ed2 100644 --- a/src/modules/users/domain/usecases/create-user.usecase.ts +++ b/src/modules/users/domain/usecases/create-user.usecase.ts @@ -30,8 +30,12 @@ export class CreateUserUseCase { this._loggingMessager.publish('user.create.info', JSON.stringify(user)); return user; } catch (error) { + let key = 'user.create.crit'; + if (error.message.includes('Already exists')) { + key = 'user.create.warning'; + } this._loggingMessager.publish( - 'user.create.critical', + key, JSON.stringify({ command, error, diff --git a/src/modules/users/domain/usecases/delete-user.usecase.ts b/src/modules/users/domain/usecases/delete-user.usecase.ts index 71f84ce..d406ff5 100644 --- a/src/modules/users/domain/usecases/delete-user.usecase.ts +++ b/src/modules/users/domain/usecases/delete-user.usecase.ts @@ -18,13 +18,13 @@ export class DeleteUserUseCase { const user = await this._repository.delete(command.uuid); this._userMessager.publish('delete', JSON.stringify({ uuid: user.uuid })); this._loggingMessager.publish( - 'delete', + 'user.delete.info', JSON.stringify({ uuid: user.uuid }), ); return user; } catch (error) { this._loggingMessager.publish( - 'user.delete.critical', + 'user.delete.crit', JSON.stringify({ command, error, diff --git a/src/modules/users/domain/usecases/update-user.usecase.ts b/src/modules/users/domain/usecases/update-user.usecase.ts index 4b83369..e2e9ddd 100644 --- a/src/modules/users/domain/usecases/update-user.usecase.ts +++ b/src/modules/users/domain/usecases/update-user.usecase.ts @@ -40,7 +40,7 @@ export class UpdateUserUseCase { return user; } catch (error) { this._loggingMessager.publish( - 'user.update.critical', + 'user.update.crit', JSON.stringify({ command, error,