mirror of
https://github.com/nestjs/nest.git
synced 2026-02-21 23:11:44 +00:00
Merge pull request #16230 from chojs23/fix/console-logger-option
fix(common): Fix skipping maxArrayLength and maxStringLength option
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user