Skip to content

Commit 8f66fd1

Browse files
author
Alexandre Piel
committed
make logger output more customizable
1 parent e019afa commit 8f66fd1

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

packages/common/services/logger.service.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,13 +77,17 @@ export class Logger implements LoggerService {
7777
this.printMessage(message, clc.yellow, context, isTimeDiffEnabled);
7878
}
7979

80+
protected static isActive(): boolean {
81+
return Logger.contextEnvironment !== NestEnvironment.TEST;
82+
}
83+
8084
private static printMessage(
8185
message: any,
8286
color: (message: string) => string,
8387
context: string = '',
8488
isTimeDiffEnabled?: boolean,
8589
) {
86-
if (Logger.contextEnvironment === NestEnvironment.TEST) {
90+
if (!this.isActive()) {
8791
return;
8892
}
8993
const output = isObject(message) ? JSON.stringify(message, null, 2) : message;
@@ -108,7 +112,7 @@ export class Logger implements LoggerService {
108112
}
109113

110114
private static printStackTrace(trace: string) {
111-
if (this.contextEnvironment === NestEnvironment.TEST || !trace) {
115+
if (!this.isActive() || !trace) {
112116
return;
113117
}
114118
process.stdout.write(trace);

0 commit comments

Comments
 (0)