Merge pull request #16230 from chojs23/fix/console-logger-option

fix(common): Fix skipping maxArrayLength and maxStringLength option
This commit is contained in:
Kamil Mysliwiec
2026-01-21 08:51:41 +01:00
committed by GitHub
2 changed files with 32 additions and 2 deletions

View File

@@ -522,10 +522,10 @@ export class ConsoleLogger implements LoggerService {
breakLength,
};
if (this.options.maxArrayLength) {
if (typeof this.options.maxArrayLength !== 'undefined') {
inspectOptions.maxArrayLength = this.options.maxArrayLength;
}
if (this.options.maxStringLength) {
if (typeof this.options.maxStringLength !== 'undefined') {
inspectOptions.maxStringLength = this.options.maxStringLength;
}

View File

@@ -897,6 +897,36 @@ describe('Logger', () => {
processStdoutWriteSpy.restore();
});
it('should respect maxStringLength when set to 0', () => {
const consoleLogger = new ConsoleLogger({
colors: false,
compact: false,
maxStringLength: 0,
});
consoleLogger.log({ name: 'abcdef' });
expect(processStdoutWriteSpy.calledOnce).to.be.true;
expect(processStdoutWriteSpy.firstCall.firstArg).to.include(
"''... 6 more characters",
);
});
it('should respect maxArrayLength when set to 0', () => {
const consoleLogger = new ConsoleLogger({
colors: false,
compact: false,
maxArrayLength: 0,
});
consoleLogger.log({ items: ['a', 'b', 'c'] });
expect(processStdoutWriteSpy.calledOnce).to.be.true;
expect(processStdoutWriteSpy.firstCall.firstArg).to.include(
'... 3 more items',
);
});
it('should support custom formatter', () => {
class CustomConsoleLogger extends ConsoleLogger {
protected formatMessage(