Optimizations (#4135)

* removes costly json serialization to InMemoryCacheAdapter

* Always cache a copy of the array

* Use own mapValues

* Makes sure we dont make unnecessary calls to the logger

* Do not bypass loggers with silent logging (only applies to stdout)

* warn is not warning

* use ===

* Wrap logRequest / logResponse in the loggerController for more granular control

Also give the ability to pass functions to the logger so we don't serialize too early in JSON (costly)

* reconfiguring winston would override the transports levels and make subsequent tests fail
This commit is contained in:
Florent Vilmart
2017-09-04 20:47:49 -04:00
committed by GitHub
parent 17f4dcd176
commit 3079270b3e
8 changed files with 118 additions and 33 deletions

View File

@@ -88,4 +88,28 @@ describe('LoggerController', () => {
}).toThrow();
done();
});
it('should replace implementations with verbose', (done) => {
const adapter = new WinstonLoggerAdapter();
const logger = new LoggerController(adapter, null, {verbose: true });
spyOn(adapter, "log");
logger.silly('yo!');
expect(adapter.log).not.toHaveBeenCalled();
done();
});
it('should replace implementations with logLevel', (done) => {
const adapter = new WinstonLoggerAdapter();
const logger = new LoggerController(adapter, null, { logLevel: 'error' });
spyOn(adapter, "log");
logger.warn('yo!');
logger.info('yo!');
logger.debug('yo!');
logger.verbose('yo!');
logger.silly('yo!');
expect(adapter.log).not.toHaveBeenCalled();
logger.error('error');
expect(adapter.log).toHaveBeenCalled();
done();
});
});