Skip to content

Commit

Permalink
Merge pull request #14 from getlarge/feat-improve-cli-logging
Browse files Browse the repository at this point in the history
feat: improve CLI loggers
  • Loading branch information
getlarge authored Apr 5, 2024
2 parents 2843d48 + 075fd52 commit 9c9e68f
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 5 deletions.
3 changes: 2 additions & 1 deletion packages/keto-cli/src/app/check-permission.command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down
4 changes: 3 additions & 1 deletion packages/keto-cli/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ import { AppModule } from './app/app.module';

async function bootstrap(): Promise<void> {
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',
Expand Down
7 changes: 6 additions & 1 deletion packages/kratos-cli/src/app/login.command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down
6 changes: 5 additions & 1 deletion packages/kratos-cli/src/app/registration.command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down
4 changes: 3 additions & 1 deletion packages/kratos-cli/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ import { AppModule } from './app/app.module';

async function bootstrap(): Promise<void> {
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',
Expand Down

0 comments on commit 9c9e68f

Please sign in to comment.