mirror of
https://github.com/CommunitySolidServer/CommunitySolidServer.git
synced 2024-10-03 14:55:10 +00:00
feat: configure logger during setup
This commit is contained in:
committed by
Ruben Taelman
parent
09ac83caa5
commit
aaa49219dc
@@ -1,6 +1,9 @@
|
||||
import streamifyArray from 'streamify-array';
|
||||
import type { AclManager } from '../authorization/AclManager';
|
||||
import { RepresentationMetadata } from '../ldp/representation/RepresentationMetadata';
|
||||
import { LazyLoggerFactory } from '../logging/LazyLoggerFactory';
|
||||
import type { LoggerFactory } from '../logging/LoggerFactory';
|
||||
import { getLoggerFor } from '../logging/LogUtil';
|
||||
import type { ExpressHttpServer } from '../server/ExpressHttpServer';
|
||||
import type { ResourceStore } from '../storage/ResourceStore';
|
||||
import { TEXT_TURTLE } from '../util/ContentTypes';
|
||||
@@ -10,9 +13,11 @@ import { CONTENT_TYPE } from '../util/UriConstants';
|
||||
* Invokes all logic to setup a server.
|
||||
*/
|
||||
export class Setup {
|
||||
protected readonly logger = getLoggerFor(this);
|
||||
private readonly httpServer: ExpressHttpServer;
|
||||
private readonly store: ResourceStore;
|
||||
private readonly aclManager: AclManager;
|
||||
private readonly loggerFactory: LoggerFactory;
|
||||
private readonly base: string;
|
||||
private readonly port: number;
|
||||
|
||||
@@ -20,12 +25,14 @@ export class Setup {
|
||||
httpServer: ExpressHttpServer,
|
||||
store: ResourceStore,
|
||||
aclManager: AclManager,
|
||||
loggerFactory: LoggerFactory,
|
||||
base: string,
|
||||
port: number,
|
||||
) {
|
||||
this.httpServer = httpServer;
|
||||
this.store = store;
|
||||
this.aclManager = aclManager;
|
||||
this.loggerFactory = loggerFactory;
|
||||
this.base = base;
|
||||
this.port = port;
|
||||
}
|
||||
@@ -34,6 +41,9 @@ export class Setup {
|
||||
* Set up a server.
|
||||
*/
|
||||
public async setup(): Promise<string> {
|
||||
// Configure the logger factory so that others can statically call it.
|
||||
LazyLoggerFactory.getInstance().setLoggerFactory(this.loggerFactory);
|
||||
|
||||
// Set up acl so everything can still be done by default
|
||||
// Note that this will need to be adapted to go through all the correct channels later on
|
||||
const aclSetup = async(): Promise<void> => {
|
||||
@@ -61,6 +71,7 @@ export class Setup {
|
||||
},
|
||||
);
|
||||
};
|
||||
this.logger.log('debug', 'Setup default ACL settings');
|
||||
await aclSetup();
|
||||
|
||||
this.httpServer.listen(this.port);
|
||||
|
||||
Reference in New Issue
Block a user