feat: configure logger during setup

This commit is contained in:
Ruben Taelman
2020-09-22 11:31:22 +02:00
committed by Ruben Taelman
parent 09ac83caa5
commit aaa49219dc
10 changed files with 100 additions and 2 deletions

View File

@@ -1,5 +1,6 @@
import { Setup } from '../../../src/init/Setup';
import type { ResourceIdentifier } from '../../../src/ldp/representation/ResourceIdentifier';
import { VoidLoggerFactory } from '../../../src/logging/VoidLoggerFactory';
describe('Setup', (): void => {
let httpServer: any;
@@ -16,7 +17,7 @@ describe('Setup', (): void => {
httpServer = {
listen: jest.fn(),
};
setup = new Setup(httpServer, store, aclManager, 'http://localhost:3000/', 3000);
setup = new Setup(httpServer, store, aclManager, new VoidLoggerFactory(), 'http://localhost:3000/', 3000);
});
it('starts an HTTP server.', async(): Promise<void> => {

View File

@@ -0,0 +1,20 @@
import { LazyLogger } from '../../../src/logging/LazyLogger';
import { LazyLoggerFactory } from '../../../src/logging/LazyLoggerFactory';
import { getLoggerFor } from '../../../src/logging/LogUtil';
import { VoidLogger } from '../../../src/logging/VoidLogger';
describe('LogUtil', (): void => {
beforeEach(async(): Promise<void> => {
LazyLoggerFactory.getInstance().setLoggerFactory(undefined);
});
it('allows creating a lazy logger for a string label.', async(): Promise<void> => {
expect(getLoggerFor('MyLabel')).toBeInstanceOf(LazyLogger);
expect((getLoggerFor('MyLabel') as any).label).toEqual('MyLabel');
});
it('allows creating a lazy logger for a class instance.', async(): Promise<void> => {
expect(getLoggerFor(new VoidLogger())).toBeInstanceOf(LazyLogger);
expect((getLoggerFor(new VoidLogger()) as any).label).toEqual('VoidLogger');
});
});