mirror of
https://github.com/nestjs/nest.git
synced 2026-02-21 23:11:44 +00:00
fix(common): Fix skipping maxArrayLength and maxStringLength option
Fixes #16229
This commit is contained in:
@@ -522,10 +522,10 @@ export class ConsoleLogger implements LoggerService {
|
|||||||
breakLength,
|
breakLength,
|
||||||
};
|
};
|
||||||
|
|
||||||
if (this.options.maxArrayLength) {
|
if (typeof this.options.maxArrayLength !== 'undefined') {
|
||||||
inspectOptions.maxArrayLength = this.options.maxArrayLength;
|
inspectOptions.maxArrayLength = this.options.maxArrayLength;
|
||||||
}
|
}
|
||||||
if (this.options.maxStringLength) {
|
if (typeof this.options.maxStringLength !== 'undefined') {
|
||||||
inspectOptions.maxStringLength = this.options.maxStringLength;
|
inspectOptions.maxStringLength = this.options.maxStringLength;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -897,6 +897,36 @@ describe('Logger', () => {
|
|||||||
processStdoutWriteSpy.restore();
|
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', () => {
|
it('should support custom formatter', () => {
|
||||||
class CustomConsoleLogger extends ConsoleLogger {
|
class CustomConsoleLogger extends ConsoleLogger {
|
||||||
protected formatMessage(
|
protected formatMessage(
|
||||||
|
|||||||
Reference in New Issue
Block a user