Skip to content

Commit 3d1b44c

Browse files
Merge pull request #16230 from chojs23/fix/console-logger-option
fix(common): Fix skipping maxArrayLength and maxStringLength option
2 parents e94951f + 979a8e2 commit 3d1b44c

File tree

2 files changed

+32
-2
lines changed

2 files changed

+32
-2
lines changed

packages/common/services/console-logger.service.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -522,10 +522,10 @@ export class ConsoleLogger implements LoggerService {
522522
breakLength,
523523
};
524524

525-
if (this.options.maxArrayLength) {
525+
if (typeof this.options.maxArrayLength !== 'undefined') {
526526
inspectOptions.maxArrayLength = this.options.maxArrayLength;
527527
}
528-
if (this.options.maxStringLength) {
528+
if (typeof this.options.maxStringLength !== 'undefined') {
529529
inspectOptions.maxStringLength = this.options.maxStringLength;
530530
}
531531

packages/common/test/services/logger.service.spec.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -897,6 +897,36 @@ describe('Logger', () => {
897897
processStdoutWriteSpy.restore();
898898
});
899899

900+
it('should respect maxStringLength when set to 0', () => {
901+
const consoleLogger = new ConsoleLogger({
902+
colors: false,
903+
compact: false,
904+
maxStringLength: 0,
905+
});
906+
907+
consoleLogger.log({ name: 'abcdef' });
908+
909+
expect(processStdoutWriteSpy.calledOnce).to.be.true;
910+
expect(processStdoutWriteSpy.firstCall.firstArg).to.include(
911+
"''... 6 more characters",
912+
);
913+
});
914+
915+
it('should respect maxArrayLength when set to 0', () => {
916+
const consoleLogger = new ConsoleLogger({
917+
colors: false,
918+
compact: false,
919+
maxArrayLength: 0,
920+
});
921+
922+
consoleLogger.log({ items: ['a', 'b', 'c'] });
923+
924+
expect(processStdoutWriteSpy.calledOnce).to.be.true;
925+
expect(processStdoutWriteSpy.firstCall.firstArg).to.include(
926+
'... 3 more items',
927+
);
928+
});
929+
900930
it('should support custom formatter', () => {
901931
class CustomConsoleLogger extends ConsoleLogger {
902932
protected formatMessage(

0 commit comments

Comments
 (0)