Skip to content

Commit

Permalink
Merge pull request #10798 from andreyddk/refactor/interact-to-nats-pi…
Browse files Browse the repository at this point in the history
…ng-timer-via-debug-flag

refactor(microservices): disable ping timer message in nats by flag
  • Loading branch information
kamilmysliwiec committed Feb 1, 2023
2 parents bb6eefc + 0cce2b9 commit afbdec6
Showing 1 changed file with 22 additions and 11 deletions.
33 changes: 22 additions & 11 deletions packages/microservices/client/client-nats.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,17 +52,28 @@ export class ClientNats extends ClientProxy {
status.data && isObject(status.data)
? JSON.stringify(status.data)
: status.data;
if (status.type === 'disconnect' || status.type === 'error') {
this.logger.error(
`NatsError: type: "${status.type}", data: "${data}".`,
);
} else {
const message = `NatsStatus: type: "${status.type}", data: "${data}".`;
if (status.type === 'pingTimer') {
this.logger.debug(message);
} else {
this.logger.log(message);
}

switch (status.type) {
case 'error':
case 'disconnect':
this.logger.error(
`NatsError: type: "${status.type}", data: "${data}".`,
);
break;

case 'pingTimer':
if (this.options.debug) {
this.logger.debug(
`NatsStatus: type: "${status.type}", data: "${data}".`,
);
}
break;

default:
this.logger.log(
`NatsStatus: type: "${status.type}", data: "${data}".`,
);
break;
}
}
}
Expand Down

0 comments on commit afbdec6

Please sign in to comment.