From 075fd52cfe386fb70f54364d1c57cad7d2adcadd Mon Sep 17 00:00:00 2001 From: getlarge Date: Fri, 5 Apr 2024 13:39:40 +0200 Subject: [PATCH] feat: improve CLI loggers --- packages/keto-cli/src/app/check-permission.command.ts | 3 ++- packages/keto-cli/src/index.ts | 4 +++- packages/kratos-cli/src/app/login.command.ts | 7 ++++++- packages/kratos-cli/src/app/registration.command.ts | 6 +++++- packages/kratos-cli/src/index.ts | 4 +++- 5 files changed, 19 insertions(+), 5 deletions(-) diff --git a/packages/keto-cli/src/app/check-permission.command.ts b/packages/keto-cli/src/app/check-permission.command.ts index d7efe44..4ea9b67 100644 --- a/packages/keto-cli/src/app/check-permission.command.ts +++ b/packages/keto-cli/src/app/check-permission.command.ts @@ -31,7 +31,8 @@ export class CheckPermissionCommand extends CommandRunner { }); } const { data } = await this.oryPermissionsService.checkPermission(tuple); - this.logger.log(`Permission ${data.allowed ? 'granted' : 'denied'}`); + this.logger.debug(`Permission ${data.allowed ? 'granted' : 'denied'}`); + this.logger.debug(data.allowed); } @Option({ diff --git a/packages/keto-cli/src/index.ts b/packages/keto-cli/src/index.ts index f560530..88ca567 100644 --- a/packages/keto-cli/src/index.ts +++ b/packages/keto-cli/src/index.ts @@ -6,7 +6,9 @@ import { AppModule } from './app/app.module'; async function bootstrap(): Promise { await CommandFactory.run(AppModule, { - logger: ['log', 'error', 'warn', 'debug', 'verbose'], + logger: process.env['DEBUG:KETO_CLI'] + ? ['log', 'error', 'warn', 'debug'] + : ['log', 'error', 'warn'], enablePositionalOptions: true, enablePassThroughOptions: true, cliName: '@getlarge/keto-cli', diff --git a/packages/kratos-cli/src/app/login.command.ts b/packages/kratos-cli/src/app/login.command.ts index 7d2a98c..1216733 100644 --- a/packages/kratos-cli/src/app/login.command.ts +++ b/packages/kratos-cli/src/app/login.command.ts @@ -88,9 +88,14 @@ export class LoginCommand extends CommandRunner { xSessionToken: sessionToken, }); - this.logger.log( + this.logger.debug( `Logged in with session: ${data.id}, token ${sessionToken}, identity ${data.identity?.id}` ); + this.logger.log({ + session: data.id, + token: sessionToken, + identity: data.identity?.id, + }); } @Option({ diff --git a/packages/kratos-cli/src/app/registration.command.ts b/packages/kratos-cli/src/app/registration.command.ts index ea8084c..de1845a 100644 --- a/packages/kratos-cli/src/app/registration.command.ts +++ b/packages/kratos-cli/src/app/registration.command.ts @@ -82,9 +82,13 @@ export class RegistrationCommand extends CommandRunner { }, }); - this.logger.log( + this.logger.debug( `Registered with email: ${email} and identity.id: ${data.identity.id}` ); + this.logger.log({ + email, + identityId: data.identity.id, + }); } @Option({ diff --git a/packages/kratos-cli/src/index.ts b/packages/kratos-cli/src/index.ts index e5d1619..97ef36c 100644 --- a/packages/kratos-cli/src/index.ts +++ b/packages/kratos-cli/src/index.ts @@ -6,7 +6,9 @@ import { AppModule } from './app/app.module'; async function bootstrap(): Promise { await CommandFactory.run(AppModule, { - logger: ['log', 'error', 'warn', 'debug', 'verbose'], + logger: process.env['DEBUG:KRATOS_CLI'] + ? ['log', 'error', 'warn', 'debug'] + : ['log', 'error', 'warn'], enablePositionalOptions: true, enablePassThroughOptions: true, cliName: '@getlarge/kratos-cli',