feat: Replace logging with external library

This commit is contained in:
Joachim Van Herwegen
2024-08-29 09:25:29 +02:00
parent 3902eccbde
commit dce39f67e8
176 changed files with 201 additions and 993 deletions

View File

@@ -1,13 +1,13 @@
import { EventEmitter } from 'node:events';
import type { IncomingMessage, Server, ServerResponse } from 'node:http';
import { Readable } from 'node:stream';
import type { Logger } from '../../../src/logging/Logger';
import { getLoggerFor } from '../../../src/logging/LogUtil';
import { getLoggerFor } from 'global-logger-factory';
import type { Logger } from 'global-logger-factory';
import { HandlerServerConfigurator } from '../../../src/server/HandlerServerConfigurator';
import type { HttpHandler } from '../../../src/server/HttpHandler';
import { flushPromises } from '../../util/Util';
jest.mock('../../../src/logging/LogUtil', (): any => {
jest.mock('global-logger-factory', (): any => {
const logger: Logger =
{ error: jest.fn(), info: jest.fn() } as any;
return { getLoggerFor: (): Logger => logger };

View File

@@ -1,8 +1,8 @@
import { EventEmitter } from 'node:events';
import type { Server } from 'node:http';
import type { WebSocket } from 'ws';
import type { Logger } from '../../../src/logging/Logger';
import { getLoggerFor } from '../../../src/logging/LogUtil';
import { getLoggerFor } from 'global-logger-factory';
import type { Logger } from 'global-logger-factory';
import type { HttpRequest } from '../../../src/server/HttpRequest';
import type { WebSocketHandler } from '../../../src/server/WebSocketHandler';
import { WebSocketServerConfigurator } from '../../../src/server/WebSocketServerConfigurator';
@@ -16,7 +16,7 @@ jest.mock('ws', (): any => ({
})),
}));
jest.mock('../../../src/logging/LogUtil', (): any => {
jest.mock('global-logger-factory', (): any => {
const logger: Logger =
{ error: jest.fn(), info: jest.fn() } as any;
return { getLoggerFor: (): Logger => logger };

View File

@@ -1,13 +1,13 @@
import { getLoggerFor } from 'global-logger-factory';
import type { Logger } from 'global-logger-factory';
import type { ResourceIdentifier } from '../../../../src/http/representation/ResourceIdentifier';
import type { Logger } from '../../../../src/logging/Logger';
import { getLoggerFor } from '../../../../src/logging/LogUtil';
import { KeyValueChannelStorage } from '../../../../src/server/notifications/KeyValueChannelStorage';
import type { NotificationChannel } from '../../../../src/server/notifications/NotificationChannel';
import type { KeyValueStorage } from '../../../../src/storage/keyvalue/KeyValueStorage';
import type { ReadWriteLocker } from '../../../../src/util/locking/ReadWriteLocker';
import resetAllMocks = jest.resetAllMocks;
jest.mock('../../../../src/logging/LogUtil', (): any => {
jest.mock('global-logger-factory', (): any => {
const logger: Logger = { info: jest.fn(), error: jest.fn() } as any;
return { getLoggerFor: (): Logger => logger };
});

View File

@@ -1,8 +1,8 @@
import { EventEmitter } from 'node:events';
import { getLoggerFor } from 'global-logger-factory';
import type { Logger } from 'global-logger-factory';
import { RepresentationMetadata } from '../../../../src/http/representation/RepresentationMetadata';
import type { ResourceIdentifier } from '../../../../src/http/representation/ResourceIdentifier';
import type { Logger } from '../../../../src/logging/Logger';
import { getLoggerFor } from '../../../../src/logging/LogUtil';
import type { ActivityEmitter } from '../../../../src/server/notifications/ActivityEmitter';
import { ListeningActivityHandler } from '../../../../src/server/notifications/ListeningActivityHandler';
import type { NotificationChannel } from '../../../../src/server/notifications/NotificationChannel';
@@ -13,7 +13,7 @@ import type { NotificationHandler } from '../../../../src/server/notifications/N
import { AS } from '../../../../src/util/Vocabularies';
import { flushPromises } from '../../../util/Util';
jest.mock('../../../../src/logging/LogUtil', (): any => {
jest.mock('global-logger-factory', (): any => {
const logger: Logger = { error: jest.fn() } as any;
return { getLoggerFor: (): Logger => logger };
});

View File

@@ -1,3 +1,5 @@
import { getLoggerFor } from 'global-logger-factory';
import type { Logger } from 'global-logger-factory';
import type { CredentialsExtractor } from '../../../../src/authentication/CredentialsExtractor';
import type { Authorizer } from '../../../../src/authorization/Authorizer';
import type { PermissionReader } from '../../../../src/authorization/PermissionReader';
@@ -6,8 +8,6 @@ import { AccessMode } from '../../../../src/authorization/permissions/Permission
import type { Operation } from '../../../../src/http/Operation';
import { BasicRepresentation } from '../../../../src/http/representation/BasicRepresentation';
import type { ResourceIdentifier } from '../../../../src/http/representation/ResourceIdentifier';
import type { Logger } from '../../../../src/logging/Logger';
import { getLoggerFor } from '../../../../src/logging/LogUtil';
import type { HttpRequest } from '../../../../src/server/HttpRequest';
import type { HttpResponse } from '../../../../src/server/HttpResponse';
import type { NotificationChannel } from '../../../../src/server/notifications/NotificationChannel';
@@ -24,7 +24,7 @@ import { IdentifierMap, IdentifierSetMultiMap } from '../../../../src/util/map/I
import { readableToString } from '../../../../src/util/StreamUtil';
import { flushPromises } from '../../../util/Util';
jest.mock('../../../../src/logging/LogUtil', (): any => {
jest.mock('global-logger-factory', (): any => {
const logger: Logger =
{ debug: jest.fn(), error: jest.fn() } as any;
return { getLoggerFor: (): Logger => logger };

View File

@@ -1,16 +1,16 @@
import { EventEmitter } from 'node:events';
import { PassThrough } from 'node:stream';
import { getLoggerFor } from 'global-logger-factory';
import type { Logger } from 'global-logger-factory';
import { RepresentationMetadata } from '../../../../../src/http/representation/RepresentationMetadata';
import type { ResourceIdentifier } from '../../../../../src/http/representation/ResourceIdentifier';
import type { Logger } from '../../../../../src/logging/Logger';
import { getLoggerFor } from '../../../../../src/logging/LogUtil';
import type { ActivityEmitter } from '../../../../../src/server/notifications/ActivityEmitter';
import type { NotificationHandler } from '../../../../../src/server/notifications/NotificationHandler';
import { AS } from '../../../../../src/util/Vocabularies';
import { flushPromises } from '../../../../util/Util';
import { StreamingHttpListeningActivityHandler, StreamingHttpMap } from '../../../../../src';
jest.mock('../../../../../src/logging/LogUtil', (): any => {
jest.mock('global-logger-factory', (): any => {
const logger: Logger = { error: jest.fn() } as any;
return { getLoggerFor: (): Logger => logger };
});

View File

@@ -1,4 +1,6 @@
import { PassThrough } from 'node:stream';
import { getLoggerFor } from 'global-logger-factory';
import type { Logger } from 'global-logger-factory';
import type { CredentialsExtractor } from '../../../../../src/authentication/CredentialsExtractor';
import type { Authorizer } from '../../../../../src/authorization/Authorizer';
import type { PermissionReader } from '../../../../../src/authorization/PermissionReader';
@@ -10,8 +12,6 @@ import type { NotificationChannel } from '../../../../../src/server/notification
import type { HttpRequest } from '../../../../../src/server/HttpRequest';
import type { HttpResponse } from '../../../../../src/server/HttpResponse';
import { BasicRepresentation } from '../../../../../src/http/representation/BasicRepresentation';
import type { Logger } from '../../../../../src/logging/Logger';
import { getLoggerFor } from '../../../../../src/logging/LogUtil';
import {
StreamingHttpRequestHandler,
@@ -23,7 +23,7 @@ import { flushPromises } from '../../../../util/Util';
import * as GuardedStream from '../../../../../src/util/GuardedStream';
jest.mock('../../../../../src/logging/LogUtil', (): any => {
jest.mock('global-logger-factory', (): any => {
const logger: Logger = { error: jest.fn(), debug: jest.fn() } as any;
return { getLoggerFor: (): Logger => logger };
});

View File

@@ -1,12 +1,12 @@
import { DataFactory, Store } from 'n3';
import { getLoggerFor } from 'global-logger-factory';
import type { Logger } from 'global-logger-factory';
import {
AbsolutePathInteractionRoute,
} from '../../../../../src/identity/interaction/routing/AbsolutePathInteractionRoute';
import {
RelativePathInteractionRoute,
} from '../../../../../src/identity/interaction/routing/RelativePathInteractionRoute';
import type { Logger } from '../../../../../src/logging/Logger';
import { getLoggerFor } from '../../../../../src/logging/LogUtil';
import { CONTEXT_NOTIFICATION } from '../../../../../src/server/notifications/Notification';
import type { NotificationChannel } from '../../../../../src/server/notifications/NotificationChannel';
import type { StateHandler } from '../../../../../src/server/notifications/StateHandler';
@@ -22,7 +22,7 @@ import quad = DataFactory.quad;
import blankNode = DataFactory.blankNode;
import namedNode = DataFactory.namedNode;
jest.mock('../../../../../src/logging/LogUtil', (): any => {
jest.mock('global-logger-factory', (): any => {
const logger: Logger =
{ error: jest.fn() } as any;
return { getLoggerFor: (): Logger => logger };

View File

@@ -1,13 +1,13 @@
import fetch from 'cross-fetch';
import { calculateJwkThumbprint, exportJWK, generateKeyPair, importJWK, jwtVerify } from 'jose';
import { getLoggerFor } from 'global-logger-factory';
import type { Logger } from 'global-logger-factory';
import { BasicRepresentation } from '../../../../../src/http/representation/BasicRepresentation';
import type { Representation } from '../../../../../src/http/representation/Representation';
import type { AlgJwk, JwkGenerator } from '../../../../../src/identity/configuration/JwkGenerator';
import {
AbsolutePathInteractionRoute,
} from '../../../../../src/identity/interaction/routing/AbsolutePathInteractionRoute';
import type { Logger } from '../../../../../src/logging/Logger';
import { getLoggerFor } from '../../../../../src/logging/LogUtil';
import type { Notification } from '../../../../../src/server/notifications/Notification';
import type {
WebhookChannel2023,
@@ -20,7 +20,7 @@ import { NOTIFY } from '../../../../../src/util/Vocabularies';
jest.mock('cross-fetch');
jest.mock('../../../../../src/logging/LogUtil', (): any => {
jest.mock('global-logger-factory', (): any => {
const logger: Logger =
{ error: jest.fn(), debug: jest.fn() } as any;
return { getLoggerFor: (): Logger => logger };