diff --git a/.componentsignore b/.componentsignore index ad294b580..8cc732861 100644 --- a/.componentsignore +++ b/.componentsignore @@ -42,7 +42,6 @@ "VariableBindings", "UnionHandler", "VirtualObject", - "WinstonLogger", "WrappedSetMultiMap", "YargsOptions" ] diff --git a/config/util/logging/no-logging.json b/config/util/logging/no-logging.json index aca7f5736..76615262d 100644 --- a/config/util/logging/no-logging.json +++ b/config/util/logging/no-logging.json @@ -1,5 +1,8 @@ { - "@context": "https://linkedsoftwaredependencies.org/bundles/npm/@solid/community-server/^7.0.0/components/context.jsonld", + "@context": [ + "https://linkedsoftwaredependencies.org/bundles/npm/@solid/community-server/^7.0.0/components/context.jsonld", + "https://linkedsoftwaredependencies.org/bundles/npm/global-logger-factory/^1.0.0/components/context.jsonld" + ], "@graph": [ { "comment": "Ignores log messages.", diff --git a/config/util/logging/winston.json b/config/util/logging/winston.json index 626754c42..d628e1967 100644 --- a/config/util/logging/winston.json +++ b/config/util/logging/winston.json @@ -1,5 +1,8 @@ { - "@context": "https://linkedsoftwaredependencies.org/bundles/npm/@solid/community-server/^7.0.0/components/context.jsonld", + "@context": [ + "https://linkedsoftwaredependencies.org/bundles/npm/@solid/community-server/^7.0.0/components/context.jsonld", + "https://linkedsoftwaredependencies.org/bundles/npm/global-logger-factory/^1.0.0/components/context.jsonld" + ], "@graph": [ { "comment": "Uses the winston library for logging", diff --git a/package.json b/package.json index 36094bc4f..29f4aa418 100644 --- a/package.json +++ b/package.json @@ -111,6 +111,7 @@ "escape-string-regexp": "^4.0.0", "fetch-sparql-endpoint": "^5.0.0", "fs-extra": "^11.1.1", + "global-logger-factory": "^1.0.0", "handlebars": "^4.7.8", "ioredis": "^5.3.2", "iso8601-duration": "^2.1.1", diff --git a/src/authentication/BearerWebIdExtractor.ts b/src/authentication/BearerWebIdExtractor.ts index 72022a29e..064dfd742 100644 --- a/src/authentication/BearerWebIdExtractor.ts +++ b/src/authentication/BearerWebIdExtractor.ts @@ -1,6 +1,6 @@ import type { SolidTokenVerifierFunction } from '@solid/access-token-verifier'; import { createSolidTokenVerifier } from '@solid/access-token-verifier'; -import { getLoggerFor } from '../logging/LogUtil'; +import { getLoggerFor } from 'global-logger-factory'; import type { HttpRequest } from '../server/HttpRequest'; import { BadRequestHttpError } from '../util/errors/BadRequestHttpError'; import { NotImplementedHttpError } from '../util/errors/NotImplementedHttpError'; diff --git a/src/authentication/DPoPWebIdExtractor.ts b/src/authentication/DPoPWebIdExtractor.ts index d539d93cb..a9fcc24d8 100644 --- a/src/authentication/DPoPWebIdExtractor.ts +++ b/src/authentication/DPoPWebIdExtractor.ts @@ -1,7 +1,7 @@ import type { RequestMethod } from '@solid/access-token-verifier'; import { createSolidTokenVerifier } from '@solid/access-token-verifier'; +import { getLoggerFor } from 'global-logger-factory'; import type { TargetExtractor } from '../http/input/identifier/TargetExtractor'; -import { getLoggerFor } from '../logging/LogUtil'; import type { HttpRequest } from '../server/HttpRequest'; import { BadRequestHttpError } from '../util/errors/BadRequestHttpError'; import { NotImplementedHttpError } from '../util/errors/NotImplementedHttpError'; diff --git a/src/authentication/UnsecureConstantCredentialsExtractor.ts b/src/authentication/UnsecureConstantCredentialsExtractor.ts index 99cc195d7..0566c4e3d 100644 --- a/src/authentication/UnsecureConstantCredentialsExtractor.ts +++ b/src/authentication/UnsecureConstantCredentialsExtractor.ts @@ -1,4 +1,4 @@ -import { getLoggerFor } from '../logging/LogUtil'; +import { getLoggerFor } from 'global-logger-factory'; import type { Credentials } from './Credentials'; import { CredentialsExtractor } from './CredentialsExtractor'; diff --git a/src/authentication/UnsecureWebIdExtractor.ts b/src/authentication/UnsecureWebIdExtractor.ts index 4e2b73a34..da2c01f92 100644 --- a/src/authentication/UnsecureWebIdExtractor.ts +++ b/src/authentication/UnsecureWebIdExtractor.ts @@ -1,4 +1,4 @@ -import { getLoggerFor } from '../logging/LogUtil'; +import { getLoggerFor } from 'global-logger-factory'; import type { HttpRequest } from '../server/HttpRequest'; import { NotImplementedHttpError } from '../util/errors/NotImplementedHttpError'; import { matchesAuthorizationScheme } from '../util/HeaderUtil'; diff --git a/src/authorization/AcpReader.ts b/src/authorization/AcpReader.ts index b1be9fe05..8cc195f82 100644 --- a/src/authorization/AcpReader.ts +++ b/src/authorization/AcpReader.ts @@ -2,10 +2,10 @@ import { Readable } from 'node:stream'; import type { IAccessControlledResource, IContext, IPolicy } from '@solid/access-control-policy'; import { allowAccessModes } from '@solid/access-control-policy'; import type { Store } from 'n3'; +import { getLoggerFor } from 'global-logger-factory'; import type { Credentials } from '../authentication/Credentials'; import type { AuxiliaryStrategy } from '../http/auxiliary/AuxiliaryStrategy'; import type { ResourceIdentifier } from '../http/representation/ResourceIdentifier'; -import { getLoggerFor } from '../logging/LogUtil'; import type { ResourceStore } from '../storage/ResourceStore'; import { INTERNAL_QUADS } from '../util/ContentTypes'; import { createErrorMessage } from '../util/errors/ErrorUtil'; diff --git a/src/authorization/AuthAuxiliaryReader.ts b/src/authorization/AuthAuxiliaryReader.ts index 555002d7e..598a28ea6 100644 --- a/src/authorization/AuthAuxiliaryReader.ts +++ b/src/authorization/AuthAuxiliaryReader.ts @@ -1,6 +1,6 @@ +import { getLoggerFor } from 'global-logger-factory'; import type { AuxiliaryStrategy } from '../http/auxiliary/AuxiliaryStrategy'; import type { ResourceIdentifier } from '../http/representation/ResourceIdentifier'; -import { getLoggerFor } from '../logging/LogUtil'; import { IdentifierSetMultiMap } from '../util/map/IdentifierMap'; import type { MapEntry } from '../util/map/MapUtil'; import { modify } from '../util/map/MapUtil'; diff --git a/src/authorization/AuxiliaryReader.ts b/src/authorization/AuxiliaryReader.ts index fcdddd15d..7776adf55 100644 --- a/src/authorization/AuxiliaryReader.ts +++ b/src/authorization/AuxiliaryReader.ts @@ -1,6 +1,6 @@ +import { getLoggerFor } from 'global-logger-factory'; import type { AuxiliaryStrategy } from '../http/auxiliary/AuxiliaryStrategy'; import type { ResourceIdentifier } from '../http/representation/ResourceIdentifier'; -import { getLoggerFor } from '../logging/LogUtil'; import { IdentifierMap, IdentifierSetMultiMap } from '../util/map/IdentifierMap'; import type { MapEntry } from '../util/map/MapUtil'; import { modify } from '../util/map/MapUtil'; diff --git a/src/authorization/OwnerPermissionReader.ts b/src/authorization/OwnerPermissionReader.ts index 2f220eadf..1eb16cb61 100644 --- a/src/authorization/OwnerPermissionReader.ts +++ b/src/authorization/OwnerPermissionReader.ts @@ -1,7 +1,7 @@ +import { getLoggerFor } from 'global-logger-factory'; import type { AuxiliaryIdentifierStrategy } from '../http/auxiliary/AuxiliaryIdentifierStrategy'; import type { ResourceIdentifier } from '../http/representation/ResourceIdentifier'; import type { PodStore } from '../identity/interaction/pod/util/PodStore'; -import { getLoggerFor } from '../logging/LogUtil'; import type { StorageLocationStrategy } from '../server/description/StorageLocationStrategy'; import { filter } from '../util/IterableUtil'; import { IdentifierMap } from '../util/map/IdentifierMap'; diff --git a/src/authorization/ParentContainerReader.ts b/src/authorization/ParentContainerReader.ts index dc6f90387..a408f2842 100644 --- a/src/authorization/ParentContainerReader.ts +++ b/src/authorization/ParentContainerReader.ts @@ -1,5 +1,5 @@ +import { getLoggerFor } from 'global-logger-factory'; import type { ResourceIdentifier } from '../http/representation/ResourceIdentifier'; -import { getLoggerFor } from '../logging/LogUtil'; import type { IdentifierStrategy } from '../util/identifiers/IdentifierStrategy'; import { IdentifierMap, IdentifierSetMultiMap } from '../util/map/IdentifierMap'; import type { MapEntry } from '../util/map/MapUtil'; diff --git a/src/authorization/PathBasedReader.ts b/src/authorization/PathBasedReader.ts index 533425d26..7f2fb5cba 100644 --- a/src/authorization/PathBasedReader.ts +++ b/src/authorization/PathBasedReader.ts @@ -1,4 +1,4 @@ -import { getLoggerFor } from '../logging/LogUtil'; +import { getLoggerFor } from 'global-logger-factory'; import { concat } from '../util/IterableUtil'; import { IdentifierMap, IdentifierSetMultiMap } from '../util/map/IdentifierMap'; import { getDefault } from '../util/map/MapUtil'; diff --git a/src/authorization/PermissionBasedAuthorizer.ts b/src/authorization/PermissionBasedAuthorizer.ts index ffcdc5b92..128bd0018 100644 --- a/src/authorization/PermissionBasedAuthorizer.ts +++ b/src/authorization/PermissionBasedAuthorizer.ts @@ -1,6 +1,6 @@ +import { getLoggerFor } from 'global-logger-factory'; import type { Credentials } from '../authentication/Credentials'; import type { ResourceIdentifier } from '../http/representation/ResourceIdentifier'; -import { getLoggerFor } from '../logging/LogUtil'; import type { ResourceSet } from '../storage/ResourceSet'; import { ForbiddenHttpError } from '../util/errors/ForbiddenHttpError'; import { NotFoundHttpError } from '../util/errors/NotFoundHttpError'; diff --git a/src/authorization/WebAclReader.ts b/src/authorization/WebAclReader.ts index 085305393..ff3439dc2 100644 --- a/src/authorization/WebAclReader.ts +++ b/src/authorization/WebAclReader.ts @@ -1,8 +1,8 @@ import { Store } from 'n3'; +import { getLoggerFor } from 'global-logger-factory'; import type { Credentials } from '../authentication/Credentials'; import type { AuxiliaryIdentifierStrategy } from '../http/auxiliary/AuxiliaryIdentifierStrategy'; import type { ResourceIdentifier } from '../http/representation/ResourceIdentifier'; -import { getLoggerFor } from '../logging/LogUtil'; import type { ResourceSet } from '../storage/ResourceSet'; import type { ResourceStore } from '../storage/ResourceStore'; import { INTERNAL_QUADS } from '../util/ContentTypes'; diff --git a/src/http/UnsecureWebSocketsProtocol.ts b/src/http/UnsecureWebSocketsProtocol.ts index c6f4e8a39..4aaa3eb75 100644 --- a/src/http/UnsecureWebSocketsProtocol.ts +++ b/src/http/UnsecureWebSocketsProtocol.ts @@ -1,8 +1,8 @@ import type { IncomingMessage } from 'node:http'; import type { TLSSocket } from 'node:tls'; import type { WebSocket } from 'ws'; +import { getLoggerFor } from 'global-logger-factory'; import type { SingleThreaded } from '../init/cluster/SingleThreaded'; -import { getLoggerFor } from '../logging/LogUtil'; import type { ActivityEmitter } from '../server/notifications/ActivityEmitter'; import type { WebSocketHandlerInput } from '../server/WebSocketHandler'; import { WebSocketHandler } from '../server/WebSocketHandler'; diff --git a/src/http/input/body/RawBodyParser.ts b/src/http/input/body/RawBodyParser.ts index 8d81d5403..0ab47ba4d 100644 --- a/src/http/input/body/RawBodyParser.ts +++ b/src/http/input/body/RawBodyParser.ts @@ -1,4 +1,4 @@ -import { getLoggerFor } from '../../../logging/LogUtil'; +import { getLoggerFor } from 'global-logger-factory'; import { BadRequestHttpError } from '../../../util/errors/BadRequestHttpError'; import { BasicRepresentation } from '../../representation/BasicRepresentation'; import type { Representation } from '../../representation/Representation'; diff --git a/src/http/input/body/SparqlUpdateBodyParser.ts b/src/http/input/body/SparqlUpdateBodyParser.ts index 73c33935b..e9d365911 100644 --- a/src/http/input/body/SparqlUpdateBodyParser.ts +++ b/src/http/input/body/SparqlUpdateBodyParser.ts @@ -1,6 +1,6 @@ import type { Algebra } from 'sparqlalgebrajs'; import { translate } from 'sparqlalgebrajs'; -import { getLoggerFor } from '../../../logging/LogUtil'; +import { getLoggerFor } from 'global-logger-factory'; import { APPLICATION_SPARQL_UPDATE } from '../../../util/ContentTypes'; import { BadRequestHttpError } from '../../../util/errors/BadRequestHttpError'; import { createErrorMessage } from '../../../util/errors/ErrorUtil'; diff --git a/src/http/input/conditions/BasicConditionsParser.ts b/src/http/input/conditions/BasicConditionsParser.ts index ef976c5d3..6ae73dc8b 100644 --- a/src/http/input/conditions/BasicConditionsParser.ts +++ b/src/http/input/conditions/BasicConditionsParser.ts @@ -1,4 +1,4 @@ -import { getLoggerFor } from '../../../logging/LogUtil'; +import { getLoggerFor } from 'global-logger-factory'; import type { HttpRequest } from '../../../server/HttpRequest'; import type { BasicConditionsOptions } from '../../../storage/conditions/BasicConditions'; import { BasicConditions } from '../../../storage/conditions/BasicConditions'; diff --git a/src/http/input/metadata/ContentLengthParser.ts b/src/http/input/metadata/ContentLengthParser.ts index a0cf84954..ee633a6ea 100644 --- a/src/http/input/metadata/ContentLengthParser.ts +++ b/src/http/input/metadata/ContentLengthParser.ts @@ -1,4 +1,4 @@ -import { getLoggerFor } from '../../../logging/LogUtil'; +import { getLoggerFor } from 'global-logger-factory'; import type { HttpRequest } from '../../../server/HttpRequest'; import type { RepresentationMetadata } from '../../representation/RepresentationMetadata'; import { MetadataParser } from './MetadataParser'; diff --git a/src/http/input/metadata/LinkRelParser.ts b/src/http/input/metadata/LinkRelParser.ts index 6e2c67c86..b128d22ff 100644 --- a/src/http/input/metadata/LinkRelParser.ts +++ b/src/http/input/metadata/LinkRelParser.ts @@ -1,7 +1,7 @@ import type { NamedNode } from '@rdfjs/types'; import { DataFactory } from 'n3'; -import type { Logger } from '../../../logging/Logger'; -import { getLoggerFor } from '../../../logging/LogUtil'; +import { getLoggerFor } from 'global-logger-factory'; +import type { Logger } from 'global-logger-factory'; import type { HttpRequest } from '../../../server/HttpRequest'; import { parseLinkHeader } from '../../../util/HeaderUtil'; import { SOLID_META } from '../../../util/Vocabularies'; diff --git a/src/http/input/metadata/PlainJsonLdFilter.ts b/src/http/input/metadata/PlainJsonLdFilter.ts index 344bf9700..2f8dad203 100644 --- a/src/http/input/metadata/PlainJsonLdFilter.ts +++ b/src/http/input/metadata/PlainJsonLdFilter.ts @@ -1,4 +1,4 @@ -import { getLoggerFor } from '../../../logging/LogUtil'; +import { getLoggerFor } from 'global-logger-factory'; import type { HttpRequest } from '../../../server/HttpRequest'; import { NotImplementedHttpError } from '../../../util/errors/NotImplementedHttpError'; import { parseContentType, parseLinkHeader } from '../../../util/HeaderUtil'; diff --git a/src/http/input/metadata/SlugParser.ts b/src/http/input/metadata/SlugParser.ts index 5de6a35a5..b910ae8c8 100644 --- a/src/http/input/metadata/SlugParser.ts +++ b/src/http/input/metadata/SlugParser.ts @@ -1,4 +1,4 @@ -import { getLoggerFor } from '../../../logging/LogUtil'; +import { getLoggerFor } from 'global-logger-factory'; import type { HttpRequest } from '../../../server/HttpRequest'; import { BadRequestHttpError } from '../../../util/errors/BadRequestHttpError'; import { SOLID_HTTP } from '../../../util/Vocabularies'; diff --git a/src/http/ldp/PatchOperationHandler.ts b/src/http/ldp/PatchOperationHandler.ts index 44fb0c95a..08ff5a246 100644 --- a/src/http/ldp/PatchOperationHandler.ts +++ b/src/http/ldp/PatchOperationHandler.ts @@ -1,4 +1,4 @@ -import { getLoggerFor } from '../../logging/LogUtil'; +import { getLoggerFor } from 'global-logger-factory'; import type { ResourceStore } from '../../storage/ResourceStore'; import { BadRequestHttpError } from '../../util/errors/BadRequestHttpError'; import { NotImplementedHttpError } from '../../util/errors/NotImplementedHttpError'; diff --git a/src/http/ldp/PostOperationHandler.ts b/src/http/ldp/PostOperationHandler.ts index a88ccc923..9e0f750b2 100644 --- a/src/http/ldp/PostOperationHandler.ts +++ b/src/http/ldp/PostOperationHandler.ts @@ -1,5 +1,5 @@ import type { Term } from '@rdfjs/types'; -import { getLoggerFor } from '../../logging/LogUtil'; +import { getLoggerFor } from 'global-logger-factory'; import type { ResourceStore } from '../../storage/ResourceStore'; import { BadRequestHttpError } from '../../util/errors/BadRequestHttpError'; import { InternalServerError } from '../../util/errors/InternalServerError'; diff --git a/src/http/ldp/PutOperationHandler.ts b/src/http/ldp/PutOperationHandler.ts index ba5a13e09..629ba1173 100644 --- a/src/http/ldp/PutOperationHandler.ts +++ b/src/http/ldp/PutOperationHandler.ts @@ -1,4 +1,4 @@ -import { getLoggerFor } from '../../logging/LogUtil'; +import { getLoggerFor } from 'global-logger-factory'; import type { ResourceStore } from '../../storage/ResourceStore'; import { BadRequestHttpError } from '../../util/errors/BadRequestHttpError'; import { MethodNotAllowedHttpError } from '../../util/errors/MethodNotAllowedHttpError'; diff --git a/src/http/output/BasicResponseWriter.ts b/src/http/output/BasicResponseWriter.ts index 6720fc0d3..e43ed10e4 100644 --- a/src/http/output/BasicResponseWriter.ts +++ b/src/http/output/BasicResponseWriter.ts @@ -1,4 +1,4 @@ -import { getLoggerFor } from '../../logging/LogUtil'; +import { getLoggerFor } from 'global-logger-factory'; import type { HttpResponse } from '../../server/HttpResponse'; import { isInternalContentType } from '../../storage/conversion/ConversionUtil'; import { NotImplementedHttpError } from '../../util/errors/NotImplementedHttpError'; diff --git a/src/http/output/error/SafeErrorHandler.ts b/src/http/output/error/SafeErrorHandler.ts index aac839e97..7c2c67d6f 100644 --- a/src/http/output/error/SafeErrorHandler.ts +++ b/src/http/output/error/SafeErrorHandler.ts @@ -1,4 +1,4 @@ -import { getLoggerFor } from '../../../logging/LogUtil'; +import { getLoggerFor } from 'global-logger-factory'; import { createErrorMessage } from '../../../util/errors/ErrorUtil'; import { guardedStreamFrom } from '../../../util/StreamUtil'; import type { ResponseDescription } from '../response/ResponseDescription'; diff --git a/src/http/output/metadata/AuxiliaryLinkMetadataWriter.ts b/src/http/output/metadata/AuxiliaryLinkMetadataWriter.ts index dd612bd2b..efa0f4809 100644 --- a/src/http/output/metadata/AuxiliaryLinkMetadataWriter.ts +++ b/src/http/output/metadata/AuxiliaryLinkMetadataWriter.ts @@ -1,4 +1,4 @@ -import { getLoggerFor } from '../../../logging/LogUtil'; +import { getLoggerFor } from 'global-logger-factory'; import type { HttpResponse } from '../../../server/HttpResponse'; import { addHeader } from '../../../util/HeaderUtil'; import { LDP, RDF, SOLID_ERROR } from '../../../util/Vocabularies'; diff --git a/src/http/output/metadata/LinkRelMetadataWriter.ts b/src/http/output/metadata/LinkRelMetadataWriter.ts index 18853dbf3..5b654ca5f 100644 --- a/src/http/output/metadata/LinkRelMetadataWriter.ts +++ b/src/http/output/metadata/LinkRelMetadataWriter.ts @@ -1,6 +1,6 @@ import type { NamedNode } from 'n3'; import { DataFactory } from 'n3'; -import { getLoggerFor } from '../../../logging/LogUtil'; +import { getLoggerFor } from 'global-logger-factory'; import type { HttpResponse } from '../../../server/HttpResponse'; import { addHeader } from '../../../util/HeaderUtil'; import type { RepresentationMetadata } from '../../representation/RepresentationMetadata'; diff --git a/src/http/output/metadata/RangeMetadataWriter.ts b/src/http/output/metadata/RangeMetadataWriter.ts index ed74efd1d..f61d33ba0 100644 --- a/src/http/output/metadata/RangeMetadataWriter.ts +++ b/src/http/output/metadata/RangeMetadataWriter.ts @@ -1,4 +1,4 @@ -import { getLoggerFor } from '../../../logging/LogUtil'; +import { getLoggerFor } from 'global-logger-factory'; import type { HttpResponse } from '../../../server/HttpResponse'; import { addHeader } from '../../../util/HeaderUtil'; import { termToInt } from '../../../util/QuadUtil'; diff --git a/src/http/output/metadata/StorageDescriptionAdvertiser.ts b/src/http/output/metadata/StorageDescriptionAdvertiser.ts index c0941b156..1325e201c 100644 --- a/src/http/output/metadata/StorageDescriptionAdvertiser.ts +++ b/src/http/output/metadata/StorageDescriptionAdvertiser.ts @@ -1,4 +1,4 @@ -import { getLoggerFor } from '../../../logging/LogUtil'; +import { getLoggerFor } from 'global-logger-factory'; import type { StorageLocationStrategy } from '../../../server/description/StorageLocationStrategy'; import { createErrorMessage } from '../../../util/errors/ErrorUtil'; import { addHeader } from '../../../util/HeaderUtil'; diff --git a/src/http/representation/RepresentationMetadata.ts b/src/http/representation/RepresentationMetadata.ts index 9dc866fc9..8b106c1ca 100644 --- a/src/http/representation/RepresentationMetadata.ts +++ b/src/http/representation/RepresentationMetadata.ts @@ -1,6 +1,6 @@ import { DataFactory, Store } from 'n3'; import type { BlankNode, DefaultGraph, Literal, NamedNode, Quad, Term } from '@rdfjs/types'; -import { getLoggerFor } from '../../logging/LogUtil'; +import { getLoggerFor } from 'global-logger-factory'; import { ContentType, SIMPLE_MEDIA_RANGE } from '../../util/Header'; import { isTerm, toLiteral, toNamedTerm, toObjectTerm } from '../../util/TermUtil'; import { CONTENT_LENGTH_TERM, CONTENT_TYPE_TERM, RDFS, SOLID_META, XSD } from '../../util/Vocabularies'; diff --git a/src/identity/AccountInitializer.ts b/src/identity/AccountInitializer.ts index 740496aeb..ca391fbef 100644 --- a/src/identity/AccountInitializer.ts +++ b/src/identity/AccountInitializer.ts @@ -1,5 +1,5 @@ +import { getLoggerFor } from 'global-logger-factory'; import { Initializer } from '../init/Initializer'; -import { getLoggerFor } from '../logging/LogUtil'; import type { AccountStore } from './interaction/account/util/AccountStore'; import type { PasswordStore } from './interaction/password/util/PasswordStore'; import type { PodCreator } from './interaction/pod/util/PodCreator'; diff --git a/src/identity/IdentityProviderHttpHandler.ts b/src/identity/IdentityProviderHttpHandler.ts index b85d1d401..ecae25cc7 100644 --- a/src/identity/IdentityProviderHttpHandler.ts +++ b/src/identity/IdentityProviderHttpHandler.ts @@ -1,6 +1,6 @@ +import { getLoggerFor } from 'global-logger-factory'; import { OkResponseDescription } from '../http/output/response/OkResponseDescription'; import type { ResponseDescription } from '../http/output/response/ResponseDescription'; -import { getLoggerFor } from '../logging/LogUtil'; import type { OperationHttpHandlerInput } from '../server/OperationHttpHandler'; import { OperationHttpHandler } from '../server/OperationHttpHandler'; import { createErrorMessage } from '../util/errors/ErrorUtil'; diff --git a/src/identity/OidcHttpHandler.ts b/src/identity/OidcHttpHandler.ts index ef3752919..12c4b74d1 100644 --- a/src/identity/OidcHttpHandler.ts +++ b/src/identity/OidcHttpHandler.ts @@ -1,4 +1,4 @@ -import { getLoggerFor } from '../logging/LogUtil'; +import { getLoggerFor } from 'global-logger-factory'; import type { HttpHandlerInput } from '../server/HttpHandler'; import { HttpHandler } from '../server/HttpHandler'; import type { ProviderFactory } from './configuration/ProviderFactory'; diff --git a/src/identity/configuration/AccountPromptFactory.ts b/src/identity/configuration/AccountPromptFactory.ts index 3979768f6..a0e612dd4 100644 --- a/src/identity/configuration/AccountPromptFactory.ts +++ b/src/identity/configuration/AccountPromptFactory.ts @@ -1,5 +1,5 @@ +import { getLoggerFor } from 'global-logger-factory'; import type { interactionPolicy, KoaContextWithOIDC } from '../../../templates/types/oidc-provider'; -import { getLoggerFor } from '../../logging/LogUtil'; import { InternalServerError } from '../../util/errors/InternalServerError'; import { importOidcProvider } from '../IdentityUtil'; import type { CookieStore } from '../interaction/account/util/CookieStore'; diff --git a/src/identity/configuration/IdentityProviderFactory.ts b/src/identity/configuration/IdentityProviderFactory.ts index 1f9f48948..4e4dbb1c1 100644 --- a/src/identity/configuration/IdentityProviderFactory.ts +++ b/src/identity/configuration/IdentityProviderFactory.ts @@ -1,5 +1,6 @@ /* eslint-disable ts/naming-convention */ import { randomBytes } from 'node:crypto'; +import { getLoggerFor } from 'global-logger-factory'; import type { Account, Adapter, @@ -14,7 +15,6 @@ import type { import type Provider from '../../../templates/types/oidc-provider'; import type { ErrorHandler } from '../../http/output/error/ErrorHandler'; import type { ResponseWriter } from '../../http/output/ResponseWriter'; -import { getLoggerFor } from '../../logging/LogUtil'; import type { KeyValueStorage } from '../../storage/keyvalue/KeyValueStorage'; import { BadRequestHttpError } from '../../util/errors/BadRequestHttpError'; import type { HttpError } from '../../util/errors/HttpError'; diff --git a/src/identity/interaction/InteractionUtil.ts b/src/identity/interaction/InteractionUtil.ts index b1a9621d4..2499b7e9b 100644 --- a/src/identity/interaction/InteractionUtil.ts +++ b/src/identity/interaction/InteractionUtil.ts @@ -1,7 +1,7 @@ +import { getLoggerFor } from 'global-logger-factory'; import type { InteractionResults } from '../../../templates/types/oidc-provider'; import type Provider from '../../../templates/types/oidc-provider'; import type { RepresentationMetadata } from '../../http/representation/RepresentationMetadata'; -import { getLoggerFor } from '../../logging/LogUtil'; import { BadRequestHttpError } from '../../util/errors/BadRequestHttpError'; import type { Json } from '../../util/Json'; import type { Interaction } from './InteractionHandler'; diff --git a/src/identity/interaction/LocationInteractionHandler.ts b/src/identity/interaction/LocationInteractionHandler.ts index 02b6ddb31..a80b73c50 100644 --- a/src/identity/interaction/LocationInteractionHandler.ts +++ b/src/identity/interaction/LocationInteractionHandler.ts @@ -1,5 +1,5 @@ +import { getLoggerFor } from 'global-logger-factory'; import { RepresentationMetadata } from '../../http/representation/RepresentationMetadata'; -import { getLoggerFor } from '../../logging/LogUtil'; import { RedirectHttpError } from '../../util/errors/RedirectHttpError'; import { SOLID_HTTP } from '../../util/Vocabularies'; import type { JsonRepresentation } from './InteractionUtil'; diff --git a/src/identity/interaction/account/util/AccountUtil.ts b/src/identity/interaction/account/util/AccountUtil.ts index 4ddce9cb6..878e8a7ee 100644 --- a/src/identity/interaction/account/util/AccountUtil.ts +++ b/src/identity/interaction/account/util/AccountUtil.ts @@ -1,4 +1,4 @@ -import { getLoggerFor } from '../../../../logging/LogUtil'; +import { getLoggerFor } from 'global-logger-factory'; import { InternalServerError } from '../../../../util/errors/InternalServerError'; import { NotFoundHttpError } from '../../../../util/errors/NotFoundHttpError'; import type { InteractionRoute } from '../../routing/InteractionRoute'; diff --git a/src/identity/interaction/account/util/BaseAccountStore.ts b/src/identity/interaction/account/util/BaseAccountStore.ts index 200d398cb..aa2717856 100644 --- a/src/identity/interaction/account/util/BaseAccountStore.ts +++ b/src/identity/interaction/account/util/BaseAccountStore.ts @@ -1,5 +1,5 @@ +import { getLoggerFor } from 'global-logger-factory'; import { Initializer } from '../../../../init/Initializer'; -import { getLoggerFor } from '../../../../logging/LogUtil'; import type { ValueType } from '../../../../storage/keyvalue/IndexedStorage'; import { createErrorMessage } from '../../../../util/errors/ErrorUtil'; import { InternalServerError } from '../../../../util/errors/InternalServerError'; diff --git a/src/identity/interaction/account/util/BaseLoginAccountStorage.ts b/src/identity/interaction/account/util/BaseLoginAccountStorage.ts index 5523aad52..fcfa01225 100644 --- a/src/identity/interaction/account/util/BaseLoginAccountStorage.ts +++ b/src/identity/interaction/account/util/BaseLoginAccountStorage.ts @@ -1,4 +1,4 @@ -import { getLoggerFor } from '../../../../logging/LogUtil'; +import { getLoggerFor } from 'global-logger-factory'; import type { CreateTypeObject, IndexedQuery, diff --git a/src/identity/interaction/client-credentials/ClientCredentialsAdapterFactory.ts b/src/identity/interaction/client-credentials/ClientCredentialsAdapterFactory.ts index 2dcf29b06..103df5749 100644 --- a/src/identity/interaction/client-credentials/ClientCredentialsAdapterFactory.ts +++ b/src/identity/interaction/client-credentials/ClientCredentialsAdapterFactory.ts @@ -1,5 +1,5 @@ +import { getLoggerFor } from 'global-logger-factory'; import type { Adapter, AdapterPayload } from '../../../../templates/types/oidc-provider'; -import { getLoggerFor } from '../../../logging/LogUtil'; import type { AdapterFactory } from '../../storage/AdapterFactory'; import { PassthroughAdapter, PassthroughAdapterFactory } from '../../storage/PassthroughAdapterFactory'; import type { WebIdStore } from '../webid/util/WebIdStore'; diff --git a/src/identity/interaction/client-credentials/ClientCredentialsDetailsHandler.ts b/src/identity/interaction/client-credentials/ClientCredentialsDetailsHandler.ts index 0bc8bcb90..d145c3c0b 100644 --- a/src/identity/interaction/client-credentials/ClientCredentialsDetailsHandler.ts +++ b/src/identity/interaction/client-credentials/ClientCredentialsDetailsHandler.ts @@ -1,4 +1,4 @@ -import { getLoggerFor } from '../../../logging/LogUtil'; +import { getLoggerFor } from 'global-logger-factory'; import { parsePath, verifyAccountId } from '../account/util/AccountUtil'; import type { JsonRepresentation } from '../InteractionUtil'; import type { JsonInteractionHandlerInput } from '../JsonInteractionHandler'; diff --git a/src/identity/interaction/client-credentials/CreateClientCredentialsHandler.ts b/src/identity/interaction/client-credentials/CreateClientCredentialsHandler.ts index 1518eb9fa..514d94c00 100644 --- a/src/identity/interaction/client-credentials/CreateClientCredentialsHandler.ts +++ b/src/identity/interaction/client-credentials/CreateClientCredentialsHandler.ts @@ -1,6 +1,6 @@ import { v4 } from 'uuid'; import { object, string } from 'yup'; -import { getLoggerFor } from '../../../logging/LogUtil'; +import { getLoggerFor } from 'global-logger-factory'; import { BadRequestHttpError } from '../../../util/errors/BadRequestHttpError'; import { sanitizeUrlPart } from '../../../util/StringUtil'; import { assertAccountId } from '../account/util/AccountUtil'; diff --git a/src/identity/interaction/client-credentials/util/BaseClientCredentialsStore.ts b/src/identity/interaction/client-credentials/util/BaseClientCredentialsStore.ts index eb075722f..83da06a7e 100644 --- a/src/identity/interaction/client-credentials/util/BaseClientCredentialsStore.ts +++ b/src/identity/interaction/client-credentials/util/BaseClientCredentialsStore.ts @@ -1,6 +1,6 @@ import { randomBytes } from 'node:crypto'; +import { getLoggerFor } from 'global-logger-factory'; import { Initializer } from '../../../../init/Initializer'; -import { getLoggerFor } from '../../../../logging/LogUtil'; import { createErrorMessage } from '../../../../util/errors/ErrorUtil'; import { InternalServerError } from '../../../../util/errors/InternalServerError'; import { ACCOUNT_TYPE } from '../../account/util/LoginStorage'; diff --git a/src/identity/interaction/login/ResolveLoginHandler.ts b/src/identity/interaction/login/ResolveLoginHandler.ts index 792877e16..94348daab 100644 --- a/src/identity/interaction/login/ResolveLoginHandler.ts +++ b/src/identity/interaction/login/ResolveLoginHandler.ts @@ -1,5 +1,5 @@ +import { getLoggerFor } from 'global-logger-factory'; import { RepresentationMetadata } from '../../../http/representation/RepresentationMetadata'; -import { getLoggerFor } from '../../../logging/LogUtil'; import type { Json } from '../../../util/Json'; import { SOLID_HTTP } from '../../../util/Vocabularies'; import { ACCOUNT_SETTINGS_REMEMBER_LOGIN } from '../account/util/AccountStore'; diff --git a/src/identity/interaction/oidc/PickWebIdHandler.ts b/src/identity/interaction/oidc/PickWebIdHandler.ts index e44009d7b..0bfd7fe8a 100644 --- a/src/identity/interaction/oidc/PickWebIdHandler.ts +++ b/src/identity/interaction/oidc/PickWebIdHandler.ts @@ -1,6 +1,6 @@ import { boolean, object, string } from 'yup'; +import { getLoggerFor } from 'global-logger-factory'; import type { InteractionResults } from '../../../../templates/types/oidc-provider'; -import { getLoggerFor } from '../../../logging/LogUtil'; import { BadRequestHttpError } from '../../../util/errors/BadRequestHttpError'; import { FoundHttpError } from '../../../util/errors/FoundHttpError'; import type { ProviderFactory } from '../../configuration/ProviderFactory'; diff --git a/src/identity/interaction/oidc/PromptHandler.ts b/src/identity/interaction/oidc/PromptHandler.ts index 20a0fed74..2cb39a7ae 100644 --- a/src/identity/interaction/oidc/PromptHandler.ts +++ b/src/identity/interaction/oidc/PromptHandler.ts @@ -1,4 +1,4 @@ -import { getLoggerFor } from '../../../logging/LogUtil'; +import { getLoggerFor } from 'global-logger-factory'; import { BadRequestHttpError } from '../../../util/errors/BadRequestHttpError'; import type { JsonRepresentation } from '../InteractionUtil'; import type { JsonInteractionHandlerInput } from '../JsonInteractionHandler'; diff --git a/src/identity/interaction/password/CreatePasswordHandler.ts b/src/identity/interaction/password/CreatePasswordHandler.ts index cceb02993..9f3a7198b 100644 --- a/src/identity/interaction/password/CreatePasswordHandler.ts +++ b/src/identity/interaction/password/CreatePasswordHandler.ts @@ -1,5 +1,5 @@ import { object, string } from 'yup'; -import { getLoggerFor } from '../../../logging/LogUtil'; +import { getLoggerFor } from 'global-logger-factory'; import { assertAccountId } from '../account/util/AccountUtil'; import type { JsonRepresentation } from '../InteractionUtil'; import { JsonInteractionHandler } from '../JsonInteractionHandler'; diff --git a/src/identity/interaction/password/ForgotPasswordHandler.ts b/src/identity/interaction/password/ForgotPasswordHandler.ts index 631dbce32..55f7155ff 100644 --- a/src/identity/interaction/password/ForgotPasswordHandler.ts +++ b/src/identity/interaction/password/ForgotPasswordHandler.ts @@ -1,5 +1,5 @@ import { object, string } from 'yup'; -import { getLoggerFor } from '../../../logging/LogUtil'; +import { getLoggerFor } from 'global-logger-factory'; import { createErrorMessage } from '../../../util/errors/ErrorUtil'; import type { TemplateEngine } from '../../../util/templates/TemplateEngine'; import type { JsonRepresentation } from '../InteractionUtil'; diff --git a/src/identity/interaction/password/PasswordLoginHandler.ts b/src/identity/interaction/password/PasswordLoginHandler.ts index 94ea8d8fb..ab77f0aac 100644 --- a/src/identity/interaction/password/PasswordLoginHandler.ts +++ b/src/identity/interaction/password/PasswordLoginHandler.ts @@ -1,5 +1,5 @@ import { boolean, object, string } from 'yup'; -import { getLoggerFor } from '../../../logging/LogUtil'; +import { getLoggerFor } from 'global-logger-factory'; import type { AccountStore } from '../account/util/AccountStore'; import type { CookieStore } from '../account/util/CookieStore'; import type { JsonRepresentation } from '../InteractionUtil'; diff --git a/src/identity/interaction/password/ResetPasswordHandler.ts b/src/identity/interaction/password/ResetPasswordHandler.ts index 6f87abebc..a4adc40e9 100644 --- a/src/identity/interaction/password/ResetPasswordHandler.ts +++ b/src/identity/interaction/password/ResetPasswordHandler.ts @@ -1,5 +1,5 @@ import { object, string } from 'yup'; -import { getLoggerFor } from '../../../logging/LogUtil'; +import { getLoggerFor } from 'global-logger-factory'; import { BadRequestHttpError } from '../../../util/errors/BadRequestHttpError'; import type { EmptyObject } from '../../../util/map/MapUtil'; import type { JsonRepresentation } from '../InteractionUtil'; diff --git a/src/identity/interaction/password/UpdatePasswordHandler.ts b/src/identity/interaction/password/UpdatePasswordHandler.ts index ce26bb59a..17f305d2f 100644 --- a/src/identity/interaction/password/UpdatePasswordHandler.ts +++ b/src/identity/interaction/password/UpdatePasswordHandler.ts @@ -1,5 +1,5 @@ import { object, string } from 'yup'; -import { getLoggerFor } from '../../../logging/LogUtil'; +import { getLoggerFor } from 'global-logger-factory'; import { BadRequestHttpError } from '../../../util/errors/BadRequestHttpError'; import type { EmptyObject } from '../../../util/map/MapUtil'; import { parsePath, verifyAccountId } from '../account/util/AccountUtil'; diff --git a/src/identity/interaction/password/util/BaseEmailSender.ts b/src/identity/interaction/password/util/BaseEmailSender.ts index 066f837ee..e39311777 100644 --- a/src/identity/interaction/password/util/BaseEmailSender.ts +++ b/src/identity/interaction/password/util/BaseEmailSender.ts @@ -1,6 +1,6 @@ import { createTransport } from 'nodemailer'; import type Mail from 'nodemailer/lib/mailer'; -import { getLoggerFor } from '../../../../logging/LogUtil'; +import { getLoggerFor } from 'global-logger-factory'; import { EmailSender } from './EmailSender'; import type { EmailArgs } from './EmailSender'; diff --git a/src/identity/interaction/password/util/BasePasswordStore.ts b/src/identity/interaction/password/util/BasePasswordStore.ts index 997f3f998..96b225259 100644 --- a/src/identity/interaction/password/util/BasePasswordStore.ts +++ b/src/identity/interaction/password/util/BasePasswordStore.ts @@ -1,6 +1,6 @@ import { compare, hash } from 'bcryptjs'; +import { getLoggerFor } from 'global-logger-factory'; import { Initializer } from '../../../../init/Initializer'; -import { getLoggerFor } from '../../../../logging/LogUtil'; import { BadRequestHttpError } from '../../../../util/errors/BadRequestHttpError'; import { createErrorMessage } from '../../../../util/errors/ErrorUtil'; import { ForbiddenHttpError } from '../../../../util/errors/ForbiddenHttpError'; diff --git a/src/identity/interaction/pod/CreatePodHandler.ts b/src/identity/interaction/pod/CreatePodHandler.ts index 394dcfab6..4d0a7e5b1 100644 --- a/src/identity/interaction/pod/CreatePodHandler.ts +++ b/src/identity/interaction/pod/CreatePodHandler.ts @@ -1,6 +1,6 @@ import type { StringSchema } from 'yup'; import { object, string } from 'yup'; -import { getLoggerFor } from '../../../logging/LogUtil'; +import { getLoggerFor } from 'global-logger-factory'; import { assertAccountId } from '../account/util/AccountUtil'; import type { JsonRepresentation } from '../InteractionUtil'; import { JsonInteractionHandler } from '../JsonInteractionHandler'; diff --git a/src/identity/interaction/pod/util/BasePodCreator.ts b/src/identity/interaction/pod/util/BasePodCreator.ts index 44841a70b..ad21c0c51 100644 --- a/src/identity/interaction/pod/util/BasePodCreator.ts +++ b/src/identity/interaction/pod/util/BasePodCreator.ts @@ -1,5 +1,5 @@ +import { getLoggerFor } from 'global-logger-factory'; import type { ResourceIdentifier } from '../../../../http/representation/ResourceIdentifier'; -import { getLoggerFor } from '../../../../logging/LogUtil'; import type { IdentifierGenerator } from '../../../../pods/generate/IdentifierGenerator'; import type { PodSettings } from '../../../../pods/settings/PodSettings'; import { BadRequestHttpError } from '../../../../util/errors/BadRequestHttpError'; diff --git a/src/identity/interaction/pod/util/BasePodStore.ts b/src/identity/interaction/pod/util/BasePodStore.ts index f6f9d2ac3..b3b5341dd 100644 --- a/src/identity/interaction/pod/util/BasePodStore.ts +++ b/src/identity/interaction/pod/util/BasePodStore.ts @@ -1,5 +1,5 @@ +import { getLoggerFor } from 'global-logger-factory'; import { Initializer } from '../../../../init/Initializer'; -import { getLoggerFor } from '../../../../logging/LogUtil'; import type { PodManager } from '../../../../pods/PodManager'; import type { PodSettings } from '../../../../pods/settings/PodSettings'; import { BadRequestHttpError } from '../../../../util/errors/BadRequestHttpError'; diff --git a/src/identity/interaction/pod/util/OwnerMetadataWriter.ts b/src/identity/interaction/pod/util/OwnerMetadataWriter.ts index f7b2cad98..b34306ebd 100644 --- a/src/identity/interaction/pod/util/OwnerMetadataWriter.ts +++ b/src/identity/interaction/pod/util/OwnerMetadataWriter.ts @@ -1,8 +1,8 @@ import { Util } from 'n3'; +import { getLoggerFor } from 'global-logger-factory'; import type { MetadataWriterInput } from '../../../../http/output/metadata/MetadataWriter'; import { MetadataWriter } from '../../../../http/output/metadata/MetadataWriter'; import type { ResourceIdentifier } from '../../../../http/representation/ResourceIdentifier'; -import { getLoggerFor } from '../../../../logging/LogUtil'; import type { StorageLocationStrategy } from '../../../../server/description/StorageLocationStrategy'; import { createErrorMessage } from '../../../../util/errors/ErrorUtil'; import { addHeader } from '../../../../util/HeaderUtil'; diff --git a/src/identity/interaction/routing/AuthorizedRouteHandler.ts b/src/identity/interaction/routing/AuthorizedRouteHandler.ts index 3e8820060..ee76dd78b 100644 --- a/src/identity/interaction/routing/AuthorizedRouteHandler.ts +++ b/src/identity/interaction/routing/AuthorizedRouteHandler.ts @@ -1,4 +1,4 @@ -import { getLoggerFor } from '../../../logging/LogUtil'; +import { getLoggerFor } from 'global-logger-factory'; import { ForbiddenHttpError } from '../../../util/errors/ForbiddenHttpError'; import { UnauthorizedHttpError } from '../../../util/errors/UnauthorizedHttpError'; import type { AccountIdRoute } from '../account/AccountIdRoute'; diff --git a/src/identity/interaction/webid/LinkWebIdHandler.ts b/src/identity/interaction/webid/LinkWebIdHandler.ts index 6815cf843..0b09768be 100644 --- a/src/identity/interaction/webid/LinkWebIdHandler.ts +++ b/src/identity/interaction/webid/LinkWebIdHandler.ts @@ -1,5 +1,5 @@ import { object } from 'yup'; -import { getLoggerFor } from '../../../logging/LogUtil'; +import { getLoggerFor } from 'global-logger-factory'; import type { StorageLocationStrategy } from '../../../server/description/StorageLocationStrategy'; import { BadRequestHttpError } from '../../../util/errors/BadRequestHttpError'; import type { OwnershipValidator } from '../../ownership/OwnershipValidator'; diff --git a/src/identity/interaction/webid/util/BaseWebIdStore.ts b/src/identity/interaction/webid/util/BaseWebIdStore.ts index 2abd2d24f..e3b5d6b27 100644 --- a/src/identity/interaction/webid/util/BaseWebIdStore.ts +++ b/src/identity/interaction/webid/util/BaseWebIdStore.ts @@ -1,5 +1,5 @@ +import { getLoggerFor } from 'global-logger-factory'; import { Initializer } from '../../../../init/Initializer'; -import { getLoggerFor } from '../../../../logging/LogUtil'; import { BadRequestHttpError } from '../../../../util/errors/BadRequestHttpError'; import { createErrorMessage } from '../../../../util/errors/ErrorUtil'; import { InternalServerError } from '../../../../util/errors/InternalServerError'; diff --git a/src/identity/ownership/NoCheckOwnershipValidator.ts b/src/identity/ownership/NoCheckOwnershipValidator.ts index 50b335557..53df7385c 100644 --- a/src/identity/ownership/NoCheckOwnershipValidator.ts +++ b/src/identity/ownership/NoCheckOwnershipValidator.ts @@ -1,4 +1,4 @@ -import { getLoggerFor } from '../../logging/LogUtil'; +import { getLoggerFor } from 'global-logger-factory'; import { OwnershipValidator } from './OwnershipValidator'; /** diff --git a/src/identity/ownership/TokenOwnershipValidator.ts b/src/identity/ownership/TokenOwnershipValidator.ts index db2dd1f55..c38b33363 100644 --- a/src/identity/ownership/TokenOwnershipValidator.ts +++ b/src/identity/ownership/TokenOwnershipValidator.ts @@ -1,7 +1,7 @@ import type { Quad } from 'n3'; import { DataFactory } from 'n3'; import { v4 } from 'uuid'; -import { getLoggerFor } from '../../logging/LogUtil'; +import { getLoggerFor } from 'global-logger-factory'; import type { ExpiringStorage } from '../../storage/keyvalue/ExpiringStorage'; import { BadRequestHttpError } from '../../util/errors/BadRequestHttpError'; import { errorTermsToMetadata } from '../../util/errors/HttpErrorUtil'; diff --git a/src/identity/storage/ClientIdAdapterFactory.ts b/src/identity/storage/ClientIdAdapterFactory.ts index 879949bb8..65995148a 100644 --- a/src/identity/storage/ClientIdAdapterFactory.ts +++ b/src/identity/storage/ClientIdAdapterFactory.ts @@ -1,8 +1,8 @@ import type { Response } from 'cross-fetch'; import { fetch } from 'cross-fetch'; import type { Quad } from 'n3'; +import { getLoggerFor } from 'global-logger-factory'; import type { Adapter, AdapterPayload } from '../../../templates/types/oidc-provider'; -import { getLoggerFor } from '../../logging/LogUtil'; import type { RepresentationConverter } from '../../storage/conversion/RepresentationConverter'; import { createErrorMessage } from '../../util/errors/ErrorUtil'; import { responseToDataset } from '../../util/FetchUtil'; diff --git a/src/identity/storage/ExpiringAdapterFactory.ts b/src/identity/storage/ExpiringAdapterFactory.ts index 27c0204b5..cb0feb690 100644 --- a/src/identity/storage/ExpiringAdapterFactory.ts +++ b/src/identity/storage/ExpiringAdapterFactory.ts @@ -1,5 +1,5 @@ +import { getLoggerFor } from 'global-logger-factory'; import type { Adapter, AdapterPayload } from '../../../templates/types/oidc-provider'; -import { getLoggerFor } from '../../logging/LogUtil'; import type { ExpiringStorage } from '../../storage/keyvalue/ExpiringStorage'; import type { AdapterFactory } from './AdapterFactory'; diff --git a/src/index.ts b/src/index.ts index 7dce018ff..f3024aa2a 100644 --- a/src/index.ts +++ b/src/index.ts @@ -307,17 +307,6 @@ export * from './init/ModuleVersionVerifier'; export * from './init/SeededAccountInitializer'; export * from './init/ServerInitializer'; -// Logging -export * from './logging/LazyLoggerFactory'; -export * from './logging/Logger'; -export * from './logging/LoggerFactory'; -export * from './logging/LogLevel'; -export * from './logging/LogUtil'; -export * from './logging/VoidLogger'; -export * from './logging/VoidLoggerFactory'; -export * from './logging/WinstonLogger'; -export * from './logging/WinstonLoggerFactory'; - // Pods/Generate/Variables export * from './pods/generate/variables/BaseUrlHandler'; export * from './pods/generate/variables/RootFilePathHandler'; diff --git a/src/init/AppRunner.ts b/src/init/AppRunner.ts index 8f09efbd7..3875496b4 100644 --- a/src/init/AppRunner.ts +++ b/src/init/AppRunner.ts @@ -4,8 +4,7 @@ import type { IComponentsManagerBuilderOptions } from 'componentsjs'; import { ComponentsManager } from 'componentsjs'; import { readJSON } from 'fs-extra'; import yargs from 'yargs'; -import { LOG_LEVELS } from '../logging/LogLevel'; -import { getLoggerFor } from '../logging/LogUtil'; +import { getLoggerFor, LOG_LEVELS } from 'global-logger-factory'; import { createErrorMessage, isError } from '../util/errors/ErrorUtil'; import { InternalServerError } from '../util/errors/InternalServerError'; import { joinFilePath, resolveAssetPath, resolveModulePath } from '../util/PathUtil'; diff --git a/src/init/BaseUrlVerifier.ts b/src/init/BaseUrlVerifier.ts index 4b2b39b4d..a1c609aec 100644 --- a/src/init/BaseUrlVerifier.ts +++ b/src/init/BaseUrlVerifier.ts @@ -1,4 +1,4 @@ -import { getLoggerFor } from '../logging/LogUtil'; +import { getLoggerFor } from 'global-logger-factory'; import type { KeyValueStorage } from '../storage/keyvalue/KeyValueStorage'; import { Initializer } from './Initializer'; diff --git a/src/init/ConfigPodInitializer.ts b/src/init/ConfigPodInitializer.ts index da5573e26..433084773 100644 --- a/src/init/ConfigPodInitializer.ts +++ b/src/init/ConfigPodInitializer.ts @@ -1,4 +1,4 @@ -import { getLoggerFor } from '../logging/LogUtil'; +import { getLoggerFor } from 'global-logger-factory'; import type { ComponentsJsFactory } from '../pods/generate/ComponentsJsFactory'; import { TEMPLATE, TEMPLATE_VARIABLE } from '../pods/generate/variables/Variables'; import type { KeyValueStorage } from '../storage/keyvalue/KeyValueStorage'; diff --git a/src/init/ContainerInitializer.ts b/src/init/ContainerInitializer.ts index 088a93911..d9ae66d27 100644 --- a/src/init/ContainerInitializer.ts +++ b/src/init/ContainerInitializer.ts @@ -1,5 +1,5 @@ +import { getLoggerFor } from 'global-logger-factory'; import type { ResourceIdentifier } from '../http/representation/ResourceIdentifier'; -import { getLoggerFor } from '../logging/LogUtil'; import type { ResourcesGenerator } from '../pods/generate/ResourcesGenerator'; import type { KeyValueStorage } from '../storage/keyvalue/KeyValueStorage'; import type { ResourceStore } from '../storage/ResourceStore'; diff --git a/src/init/LoggerInitializer.ts b/src/init/LoggerInitializer.ts index 6dcdaf3a4..99ad16c6f 100644 --- a/src/init/LoggerInitializer.ts +++ b/src/init/LoggerInitializer.ts @@ -1,5 +1,5 @@ -import type { LoggerFactory } from '../logging/LoggerFactory'; -import { setGlobalLoggerFactory } from '../logging/LogUtil'; +import type { LoggerFactory } from 'global-logger-factory'; +import { setGlobalLoggerFactory } from 'global-logger-factory'; import { Initializer } from './Initializer'; /** diff --git a/src/init/SeededAccountInitializer.ts b/src/init/SeededAccountInitializer.ts index 19fa50481..f0a80ee73 100644 --- a/src/init/SeededAccountInitializer.ts +++ b/src/init/SeededAccountInitializer.ts @@ -1,10 +1,10 @@ import { readJson } from 'fs-extra'; import { array, object, string } from 'yup'; +import { getLoggerFor } from 'global-logger-factory'; import type { AccountStore } from '../identity/interaction/account/util/AccountStore'; import type { PasswordStore } from '../identity/interaction/password/util/PasswordStore'; import type { PodCreator } from '../identity/interaction/pod/util/PodCreator'; import { URL_SCHEMA } from '../identity/interaction/YupUtil'; -import { getLoggerFor } from '../logging/LogUtil'; import { createErrorMessage } from '../util/errors/ErrorUtil'; import { Initializer } from './Initializer'; diff --git a/src/init/ServerInitializer.ts b/src/init/ServerInitializer.ts index 27afa4002..eeecc2e42 100644 --- a/src/init/ServerInitializer.ts +++ b/src/init/ServerInitializer.ts @@ -1,6 +1,6 @@ import type { Server } from 'node:http'; import { promisify } from 'node:util'; -import { getLoggerFor } from '../logging/LogUtil'; +import { getLoggerFor } from 'global-logger-factory'; import { isHttpsServer } from '../server/HttpServerFactory'; import type { HttpServerFactory } from '../server/HttpServerFactory'; import type { Finalizable } from './final/Finalizable'; diff --git a/src/init/cluster/ClusterManager.ts b/src/init/cluster/ClusterManager.ts index 1bbfcdeaa..93c89d780 100644 --- a/src/init/cluster/ClusterManager.ts +++ b/src/init/cluster/ClusterManager.ts @@ -1,7 +1,7 @@ import type { Worker } from 'node:cluster'; import cluster from 'node:cluster'; import { cpus } from 'node:os'; -import { getLoggerFor } from '../../logging/LogUtil'; +import { getLoggerFor } from 'global-logger-factory'; import { InternalServerError } from '../../util/errors/InternalServerError'; /** diff --git a/src/init/migration/V6MigrationInitializer.ts b/src/init/migration/V6MigrationInitializer.ts index 6d765f21c..616b3451a 100644 --- a/src/init/migration/V6MigrationInitializer.ts +++ b/src/init/migration/V6MigrationInitializer.ts @@ -1,4 +1,5 @@ import { createInterface } from 'node:readline'; +import { getLoggerFor } from 'global-logger-factory'; import { ACCOUNT_STORAGE_DESCRIPTION } from '../../identity/interaction/account/util/BaseAccountStore'; import type { AccountLoginStorage } from '../../identity/interaction/account/util/LoginStorage'; import { ACCOUNT_TYPE } from '../../identity/interaction/account/util/LoginStorage'; @@ -17,7 +18,6 @@ import { POD_STORAGE_TYPE, } from '../../identity/interaction/pod/util/BasePodStore'; import { WEBID_STORAGE_DESCRIPTION, WEBID_STORAGE_TYPE } from '../../identity/interaction/webid/util/BaseWebIdStore'; -import { getLoggerFor } from '../../logging/LogUtil'; import type { KeyValueStorage } from '../../storage/keyvalue/KeyValueStorage'; import { Initializer } from '../Initializer'; diff --git a/src/logging/LazyLoggerFactory.ts b/src/logging/LazyLoggerFactory.ts deleted file mode 100644 index e6f3a9a2f..000000000 --- a/src/logging/LazyLoggerFactory.ts +++ /dev/null @@ -1,93 +0,0 @@ -import cluster from 'node:cluster'; -import { WrappingLogger } from './Logger'; -import type { Logger } from './Logger'; -import type { LoggerFactory } from './LoggerFactory'; -import type { LogLevel } from './LogLevel'; - -/** - * Temporary {@link LoggerFactory} that buffers log messages in memory - * until the {@link TemporaryLoggerFactory#switch} method is called. - */ -class TemporaryLoggerFactory implements LoggerFactory { - private bufferSpaces: number; - private readonly wrappers: { wrapper: WrappingLogger; label: string }[] = []; - private readonly buffer: { logger: Logger; level: LogLevel; message: string }[] = []; - - public constructor(bufferSize = 1024) { - this.bufferSpaces = bufferSize; - } - - public createLogger(label: string): WrappingLogger { - const wrapper = new WrappingLogger({ - log: (level: LogLevel, message: string): Logger => - this.bufferLogEntry(wrapper, level, message), - }); - this.wrappers.push({ wrapper, label }); - return wrapper; - } - - private bufferLogEntry(logger: WrappingLogger, level: LogLevel, message: string): Logger { - // Buffer the message if spaces are still available - if (this.bufferSpaces > 0) { - this.bufferSpaces -= 1; - // If this is the last space, instead generate a warning through a new logger - if (this.bufferSpaces === 0) { - logger = this.createLogger('LazyLoggerFactory'); - level = 'warn'; - message = `Memory-buffered logging limit of ${this.buffer.length + 1} reached`; - } - this.buffer.push({ logger, level, message }); - } - return logger; - } - - /** - * Swaps all lazy loggers to new loggers from the given factory, - * and emits any buffered messages through those actual loggers. - */ - public switch(loggerFactory: LoggerFactory): void { - // Instantiate an actual logger within every lazy logger - for (const { wrapper, label } of this.wrappers.splice(0, this.wrappers.length)) { - wrapper.logger = loggerFactory.createLogger(label); - } - // Emit all buffered log messages - for (const { logger, level, message } of this.buffer.splice(0, this.buffer.length)) { - logger.log(level, message, { isPrimary: cluster.isMaster, pid: process.pid }); - } - } -} - -/** - * Wraps around another {@link LoggerFactory} that can be set lazily. - * This is useful when objects are instantiated (and when they create loggers) - * before the logging system has been fully instantiated, - * as is the case when using a dependency injection framework such as Components.js. - * - * Loggers can be created even before a {@link LoggerFactory} is set; - * any log messages will be buffered and re-emitted. - */ -export class LazyLoggerFactory implements LoggerFactory { - private factory: LoggerFactory; - - public constructor(options: { bufferSize?: number } = {}) { - this.factory = new TemporaryLoggerFactory(options.bufferSize); - } - - public get loggerFactory(): LoggerFactory { - if (this.factory instanceof TemporaryLoggerFactory) { - throw new TypeError('Logger factory not yet set.'); - } - return this.factory; - } - - public set loggerFactory(loggerFactory: LoggerFactory) { - if (this.factory instanceof TemporaryLoggerFactory) { - this.factory.switch(loggerFactory); - } - this.factory = loggerFactory; - } - - public createLogger(label: string): Logger { - return this.factory.createLogger(label); - } -} diff --git a/src/logging/LogLevel.ts b/src/logging/LogLevel.ts deleted file mode 100644 index 136944833..000000000 --- a/src/logging/LogLevel.ts +++ /dev/null @@ -1,6 +0,0 @@ -export const LOG_LEVELS = [ 'error', 'warn', 'info', 'verbose', 'debug', 'silly' ] as const; - -/** - * Different log levels, from most important to least important. - */ -export type LogLevel = typeof LOG_LEVELS[number]; diff --git a/src/logging/LogUtil.ts b/src/logging/LogUtil.ts deleted file mode 100644 index 2498b09cd..000000000 --- a/src/logging/LogUtil.ts +++ /dev/null @@ -1,73 +0,0 @@ -import { LazyLoggerFactory } from './LazyLoggerFactory'; -import type { Logger } from './Logger'; -import type { LoggerFactory } from './LoggerFactory'; - -let loggerFactoryWrapper = new LazyLoggerFactory(); -let classLoggers = new WeakMap(); - -/** - * Gets a logger instance for the given class instance. - * - * The following shows a typical pattern on how to create loggers: - * ``` - * class MyClass { - * protected readonly logger = getLoggerFor(this); - * } - * ``` - * If no class is applicable, a logger can also be created as follows: - * ``` - * const logger = getLoggerFor('MyFunction'); - * ``` - * - * @param loggable - A class instance or a class string name. - */ -export function getLoggerFor(loggable: string | Instance): Logger { - let logger: Logger; - // Create a logger with a text label - if (typeof loggable === 'string') { - logger = loggerFactoryWrapper.createLogger(loggable); - // Create or reuse a logger for a specific class - } else { - const { constructor } = loggable; - if (classLoggers.has(constructor)) { - logger = classLoggers.get(constructor)!; - } else { - logger = loggerFactoryWrapper.createLogger(constructor.name); - classLoggers.set(constructor, logger); - } - } - return logger; -} - -/** - * Sets the global logger factory. - * This causes loggers created by {@link getLoggerFor} to delegate to a logger from the given factory. - * - * @param loggerFactory - A logger factory. - */ -export function setGlobalLoggerFactory(loggerFactory: LoggerFactory): void { - loggerFactoryWrapper.loggerFactory = loggerFactory; -} - -/** - * Resets the internal logger factory, which holds the global logger factory. - * For testing purposes only. - */ -export function resetInternalLoggerFactory(factory = new LazyLoggerFactory()): void { - loggerFactoryWrapper = factory; - classLoggers = new WeakMap(); -} - -/** - * Any class constructor. - */ -interface Constructor { - name: string; -} - -/** - * Any class instance. - */ -interface Instance { - constructor: Constructor; -} diff --git a/src/logging/Logger.ts b/src/logging/Logger.ts deleted file mode 100644 index 62f69e593..000000000 --- a/src/logging/Logger.ts +++ /dev/null @@ -1,146 +0,0 @@ -import cluster from 'node:cluster'; -import type { LogLevel } from './LogLevel'; - -export interface LogMetadata { - /** Is the current process the Primary process */ - isPrimary: boolean; - /** The process id of the current process */ - pid: number; -} - -/** - * Logs messages on a specific level. - * - * @see getLoggerFor on how to instantiate loggers. - */ -export interface SimpleLogger { - /** - * Log the given message at the given level. - * If the internal level is higher than the given level, the message may be voided. - * - * @param level - The level to log at. - * @param message - The message to log. - * @param meta - Optional metadata to include in the log message. - */ - log: (level: LogLevel, message: string, meta?: LogMetadata) => SimpleLogger; -} - -/** - * Logs messages, with convenience methods to log on a specific level. - * - * @see getLoggerFor on how to instantiate loggers. - */ -export interface Logger extends SimpleLogger { - /** - * Log the given message at the given level. - * If the internal level is higher than the given level, the message may be voided. - * - * @param level - The level to log at. - * @param message - The message to log. - * @param meta - Optional metadata to include in the log message. - */ - log: (level: LogLevel, message: string, meta?: LogMetadata) => Logger; - - /** - * Log a message at the 'error' level. - * - * @param message - The message to log. - * @param meta - Optional metadata to include in the log message. - */ - error: (message: string) => Logger; - - /** - * Log a message at the 'warn' level. - * - * @param message - The message to log. - * @param meta - Optional metadata to include in the log message. - */ - warn: (message: string) => Logger; - - /** - * Log a message at the 'info' level. - * - * @param message - The message to log. - * @param meta - Optional metadata to include in the log message. - */ - info: (message: string) => Logger; - - /** - * Log a message at the 'verbose' level. - * - * @param message - The message to log. - * @param meta - Optional metadata to include in the log message. - */ - verbose: (message: string) => Logger; - - /** - * Log a message at the 'debug' level. - * - * @param message - The message to log. - * @param meta - Optional metadata to include in the log message. - */ - debug: (message: string) => Logger; - - /** - * Log a message at the 'silly' level. - * - * @param message - The message to log. - * @param meta - Optional metadata to include in the log message. - */ - silly: (message: string) => Logger; -} - -/** - * Base class that implements all additional {@link BaseLogger} methods, - * leaving only the implementation of {@link SimpleLogger}. - */ -export abstract class BaseLogger implements Logger { - public abstract log(level: LogLevel, message: string, meta?: LogMetadata): Logger; - - private readonly getMeta = (): LogMetadata => ({ - pid: process.pid, - isPrimary: cluster.isMaster, - }); - - public error(message: string): Logger { - return this.log('error', message, this.getMeta()); - } - - public warn(message: string): Logger { - return this.log('warn', message, this.getMeta()); - } - - public info(message: string): Logger { - return this.log('info', message, this.getMeta()); - } - - public verbose(message: string): Logger { - return this.log('verbose', message, this.getMeta()); - } - - public debug(message: string): Logger { - return this.log('debug', message, this.getMeta()); - } - - public silly(message: string): Logger { - return this.log('silly', message, this.getMeta()); - } -} - -/** - * Implements {@link BaseLogger} around a {@link SimpleLogger}, - * which can be swapped out a runtime. - */ -export class WrappingLogger extends BaseLogger { - public logger: SimpleLogger; - - public constructor(logger: SimpleLogger) { - super(); - this.logger = logger; - } - - public log(level: LogLevel, message: string, meta?: LogMetadata): this { - this.logger.log(level, message, meta); - return this; - } -} diff --git a/src/logging/LoggerFactory.ts b/src/logging/LoggerFactory.ts deleted file mode 100644 index 34dd279c1..000000000 --- a/src/logging/LoggerFactory.ts +++ /dev/null @@ -1,13 +0,0 @@ -import type { Logger } from './Logger'; - -/** - * Instantiates new logger instances. - */ -export interface LoggerFactory { - /** - * Create a logger instance for the given label. - * - * @param label - A label that is used to identify the given logger. - */ - createLogger: (label: string) => Logger; -} diff --git a/src/logging/VoidLogger.ts b/src/logging/VoidLogger.ts deleted file mode 100644 index 834e09958..000000000 --- a/src/logging/VoidLogger.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { BaseLogger } from './Logger'; - -/** - * A logger that does nothing on a log message. - */ -export class VoidLogger extends BaseLogger { - public log(): this { - // Do nothing - return this; - } -} diff --git a/src/logging/VoidLoggerFactory.ts b/src/logging/VoidLoggerFactory.ts deleted file mode 100644 index d44ed6923..000000000 --- a/src/logging/VoidLoggerFactory.ts +++ /dev/null @@ -1,14 +0,0 @@ -import type { LoggerFactory } from './LoggerFactory'; -import { VoidLogger } from './VoidLogger'; - -/** - * A factory that always returns {@link VoidLogger}, which does nothing on log messages. - */ -export class VoidLoggerFactory implements LoggerFactory { - private readonly logger = new VoidLogger(); - - // eslint-disable-next-line unused-imports/no-unused-vars - public createLogger(label: string): VoidLogger { - return this.logger; - } -} diff --git a/src/logging/WinstonLogger.ts b/src/logging/WinstonLogger.ts deleted file mode 100644 index 86381e357..000000000 --- a/src/logging/WinstonLogger.ts +++ /dev/null @@ -1,20 +0,0 @@ -import type { Logger as WinstonInnerLogger } from 'winston'; -import { BaseLogger } from './Logger'; -import type { LogLevel } from './LogLevel'; - -/** - * A WinstonLogger implements the {@link Logger} interface using a given winston logger. - */ -export class WinstonLogger extends BaseLogger { - private readonly logger: WinstonInnerLogger; - - public constructor(logger: WinstonInnerLogger) { - super(); - this.logger = logger; - } - - public log(level: LogLevel, message: string, meta?: unknown): this { - this.logger.log(level, message, meta); - return this; - } -} diff --git a/src/logging/WinstonLoggerFactory.ts b/src/logging/WinstonLoggerFactory.ts deleted file mode 100644 index 66e0c5873..000000000 --- a/src/logging/WinstonLoggerFactory.ts +++ /dev/null @@ -1,48 +0,0 @@ -import type { TransformableInfo } from 'logform'; -import { createLogger, format, transports } from 'winston'; -import type * as Transport from 'winston-transport'; -import type { Logger, LogMetadata } from './Logger'; -import type { LoggerFactory } from './LoggerFactory'; -import { WinstonLogger } from './WinstonLogger'; - -/** - * Uses the winston library to create loggers for the given logging level. - * By default, it will print to the console with colorized logging levels. - * - * This creates instances of {@link WinstonLogger}. - */ -export class WinstonLoggerFactory implements LoggerFactory { - private readonly level: string; - - public constructor(level: string) { - this.level = level; - } - - private readonly clusterInfo = (meta: LogMetadata): string => { - if (meta.isPrimary) { - return 'Primary'; - } - return `W-${meta.pid ?? '???'}`; - }; - - public createLogger(label: string): Logger { - return new WinstonLogger(createLogger({ - level: this.level, - format: format.combine( - format.label({ label }), - format.colorize(), - format.timestamp(), - format.metadata({ fillExcept: [ 'level', 'timestamp', 'label', 'message' ]}), - format.printf( - ({ level: levelInner, message, label: labelInner, timestamp, metadata: meta }: TransformableInfo): string => - `${timestamp} [${labelInner}] {${this.clusterInfo(meta as LogMetadata)}} ${levelInner}: ${message}`, - ), - ), - transports: this.createTransports(), - })); - } - - protected createTransports(): Transport[] { - return [ new transports.Console() ]; - } -} diff --git a/src/pods/ConfigPodManager.ts b/src/pods/ConfigPodManager.ts index bd7bc7c6f..a105e47d7 100644 --- a/src/pods/ConfigPodManager.ts +++ b/src/pods/ConfigPodManager.ts @@ -1,4 +1,4 @@ -import { getLoggerFor } from '../logging/LogUtil'; +import { getLoggerFor } from 'global-logger-factory'; import type { KeyValueStorage } from '../storage/keyvalue/KeyValueStorage'; import type { ResourceStore } from '../storage/ResourceStore'; import { addGeneratedResources } from './generate/GenerateUtil'; diff --git a/src/pods/GeneratedPodManager.ts b/src/pods/GeneratedPodManager.ts index 142675f44..3c2cb5bdc 100644 --- a/src/pods/GeneratedPodManager.ts +++ b/src/pods/GeneratedPodManager.ts @@ -1,4 +1,4 @@ -import { getLoggerFor } from '../logging/LogUtil'; +import { getLoggerFor } from 'global-logger-factory'; import type { ResourceStore } from '../storage/ResourceStore'; import { ConflictHttpError } from '../util/errors/ConflictHttpError'; import { addGeneratedResources } from './generate/GenerateUtil'; diff --git a/src/pods/generate/BaseResourcesGenerator.ts b/src/pods/generate/BaseResourcesGenerator.ts index a86ef3bfd..25505dcc7 100644 --- a/src/pods/generate/BaseResourcesGenerator.ts +++ b/src/pods/generate/BaseResourcesGenerator.ts @@ -2,11 +2,11 @@ import { createReadStream, promises as fsPromises } from 'node:fs'; import type { Readable } from 'node:stream'; import { pathExists } from 'fs-extra'; import { Parser } from 'n3'; +import { getLoggerFor } from 'global-logger-factory'; import type { AuxiliaryStrategy } from '../../http/auxiliary/AuxiliaryStrategy'; import { BasicRepresentation } from '../../http/representation/BasicRepresentation'; import { RepresentationMetadata } from '../../http/representation/RepresentationMetadata'; import type { ResourceIdentifier } from '../../http/representation/ResourceIdentifier'; -import { getLoggerFor } from '../../logging/LogUtil'; import type { FileIdentifierMapper, FileIdentifierMapperFactory, diff --git a/src/pods/generate/TemplatedPodGenerator.ts b/src/pods/generate/TemplatedPodGenerator.ts index 77a04648f..9cc99ed95 100644 --- a/src/pods/generate/TemplatedPodGenerator.ts +++ b/src/pods/generate/TemplatedPodGenerator.ts @@ -1,4 +1,4 @@ -import { getLoggerFor } from '../../logging/LogUtil'; +import { getLoggerFor } from 'global-logger-factory'; import type { KeyValueStorage } from '../../storage/keyvalue/KeyValueStorage'; import type { ResourceStore } from '../../storage/ResourceStore'; import { BadRequestHttpError } from '../../util/errors/BadRequestHttpError'; diff --git a/src/server/AuthorizingHttpHandler.ts b/src/server/AuthorizingHttpHandler.ts index 0820e273a..d02119f43 100644 --- a/src/server/AuthorizingHttpHandler.ts +++ b/src/server/AuthorizingHttpHandler.ts @@ -1,4 +1,5 @@ import { DataFactory } from 'n3'; +import { getLoggerFor } from 'global-logger-factory'; import type { Credentials } from '../authentication/Credentials'; import type { CredentialsExtractor } from '../authentication/CredentialsExtractor'; import type { Authorizer } from '../authorization/Authorizer'; @@ -6,7 +7,6 @@ import type { PermissionReader } from '../authorization/PermissionReader'; import type { ModesExtractor } from '../authorization/permissions/ModesExtractor'; import type { AccessMap } from '../authorization/permissions/Permissions'; import type { ResponseDescription } from '../http/output/response/ResponseDescription'; -import { getLoggerFor } from '../logging/LogUtil'; import { createErrorMessage } from '../util/errors/ErrorUtil'; import { HttpError } from '../util/errors/HttpError'; import { SOLID_META } from '../util/Vocabularies'; diff --git a/src/server/BaseServerFactory.ts b/src/server/BaseServerFactory.ts index 421522fb6..81f06e4f9 100644 --- a/src/server/BaseServerFactory.ts +++ b/src/server/BaseServerFactory.ts @@ -3,7 +3,7 @@ import type { Server } from 'node:http'; import { createServer as createHttpServer } from 'node:http'; import type { ServerOptions } from 'node:https'; import { createServer as createHttpsServer } from 'node:https'; -import { getLoggerFor } from '../logging/LogUtil'; +import { getLoggerFor } from 'global-logger-factory'; import type { HttpServerFactory } from './HttpServerFactory'; import type { ServerConfigurator } from './ServerConfigurator'; diff --git a/src/server/HandlerServerConfigurator.ts b/src/server/HandlerServerConfigurator.ts index d46596bef..247c5a725 100644 --- a/src/server/HandlerServerConfigurator.ts +++ b/src/server/HandlerServerConfigurator.ts @@ -1,5 +1,5 @@ import type { IncomingMessage, Server, ServerResponse } from 'node:http'; -import { getLoggerFor } from '../logging/LogUtil'; +import { getLoggerFor } from 'global-logger-factory'; import { isError } from '../util/errors/ErrorUtil'; import { guardStream } from '../util/GuardedStream'; import type { HttpHandler } from './HttpHandler'; diff --git a/src/server/ParsingHttpHandler.ts b/src/server/ParsingHttpHandler.ts index fe620c924..765cf3cff 100644 --- a/src/server/ParsingHttpHandler.ts +++ b/src/server/ParsingHttpHandler.ts @@ -1,8 +1,8 @@ +import { getLoggerFor } from 'global-logger-factory'; import type { RequestParser } from '../http/input/RequestParser'; import type { ErrorHandler } from '../http/output/error/ErrorHandler'; import type { ResponseDescription } from '../http/output/response/ResponseDescription'; import type { ResponseWriter } from '../http/output/ResponseWriter'; -import { getLoggerFor } from '../logging/LogUtil'; import { createErrorMessage } from '../util/errors/ErrorUtil'; import { HttpError } from '../util/errors/HttpError'; import { InternalServerError } from '../util/errors/InternalServerError'; diff --git a/src/server/WacAllowHttpHandler.ts b/src/server/WacAllowHttpHandler.ts index cb674a836..31ceb0d78 100644 --- a/src/server/WacAllowHttpHandler.ts +++ b/src/server/WacAllowHttpHandler.ts @@ -1,3 +1,4 @@ +import { getLoggerFor } from 'global-logger-factory'; import type { Credentials } from '../authentication/Credentials'; import type { CredentialsExtractor } from '../authentication/CredentialsExtractor'; import type { PermissionReader } from '../authorization/PermissionReader'; @@ -7,7 +8,6 @@ import type { ModesExtractor } from '../authorization/permissions/ModesExtractor import { AccessMode } from '../authorization/permissions/Permissions'; import type { ResponseDescription } from '../http/output/response/ResponseDescription'; import type { RepresentationMetadata } from '../http/representation/RepresentationMetadata'; -import { getLoggerFor } from '../logging/LogUtil'; import { NotModifiedHttpError } from '../util/errors/NotModifiedHttpError'; import { ACL, AUTH } from '../util/Vocabularies'; import type { OperationHttpHandlerInput } from './OperationHttpHandler'; diff --git a/src/server/WebSocketServerConfigurator.ts b/src/server/WebSocketServerConfigurator.ts index b7ccbc664..e277f2393 100644 --- a/src/server/WebSocketServerConfigurator.ts +++ b/src/server/WebSocketServerConfigurator.ts @@ -2,7 +2,7 @@ import type { IncomingMessage, Server } from 'node:http'; import type { Socket } from 'node:net'; import type { WebSocket } from 'ws'; import { WebSocketServer } from 'ws'; -import { getLoggerFor } from '../logging/LogUtil'; +import { getLoggerFor } from 'global-logger-factory'; import { createErrorMessage } from '../util/errors/ErrorUtil'; import { guardStream } from '../util/GuardedStream'; import { ServerConfigurator } from './ServerConfigurator'; diff --git a/src/server/middleware/StaticAssetHandler.ts b/src/server/middleware/StaticAssetHandler.ts index 33b58c8f9..ce49005d8 100644 --- a/src/server/middleware/StaticAssetHandler.ts +++ b/src/server/middleware/StaticAssetHandler.ts @@ -1,7 +1,7 @@ import { createReadStream } from 'node:fs'; import escapeStringRegexp from 'escape-string-regexp'; import * as mime from 'mime-types'; -import { getLoggerFor } from '../../logging/LogUtil'; +import { getLoggerFor } from 'global-logger-factory'; import { APPLICATION_OCTET_STREAM } from '../../util/ContentTypes'; import { InternalServerError } from '../../util/errors/InternalServerError'; import { NotFoundHttpError } from '../../util/errors/NotFoundHttpError'; diff --git a/src/server/notifications/BaseStateHandler.ts b/src/server/notifications/BaseStateHandler.ts index 04232bac7..96d40ed48 100644 --- a/src/server/notifications/BaseStateHandler.ts +++ b/src/server/notifications/BaseStateHandler.ts @@ -1,4 +1,4 @@ -import { getLoggerFor } from '../../logging/LogUtil'; +import { getLoggerFor } from 'global-logger-factory'; import { createErrorMessage } from '../../util/errors/ErrorUtil'; import type { NotificationChannel } from './NotificationChannel'; import type { NotificationChannelStorage } from './NotificationChannelStorage'; diff --git a/src/server/notifications/KeyValueChannelStorage.ts b/src/server/notifications/KeyValueChannelStorage.ts index 073f65837..9ca0b75cd 100644 --- a/src/server/notifications/KeyValueChannelStorage.ts +++ b/src/server/notifications/KeyValueChannelStorage.ts @@ -1,5 +1,5 @@ +import { getLoggerFor } from 'global-logger-factory'; import type { ResourceIdentifier } from '../../http/representation/ResourceIdentifier'; -import { getLoggerFor } from '../../logging/LogUtil'; import type { KeyValueStorage } from '../../storage/keyvalue/KeyValueStorage'; import { InternalServerError } from '../../util/errors/InternalServerError'; import type { ReadWriteLocker } from '../../util/locking/ReadWriteLocker'; diff --git a/src/server/notifications/ListeningActivityHandler.ts b/src/server/notifications/ListeningActivityHandler.ts index a5c5ff690..703b5e783 100644 --- a/src/server/notifications/ListeningActivityHandler.ts +++ b/src/server/notifications/ListeningActivityHandler.ts @@ -1,6 +1,6 @@ +import { getLoggerFor } from 'global-logger-factory'; import type { RepresentationMetadata } from '../../http/representation/RepresentationMetadata'; import type { ResourceIdentifier } from '../../http/representation/ResourceIdentifier'; -import { getLoggerFor } from '../../logging/LogUtil'; import { createErrorMessage } from '../../util/errors/ErrorUtil'; import { StaticHandler } from '../../util/handlers/StaticHandler'; import type { AS, VocabularyTerm } from '../../util/Vocabularies'; diff --git a/src/server/notifications/NotificationSubscriber.ts b/src/server/notifications/NotificationSubscriber.ts index 96bab2b77..04b053761 100644 --- a/src/server/notifications/NotificationSubscriber.ts +++ b/src/server/notifications/NotificationSubscriber.ts @@ -1,3 +1,4 @@ +import { getLoggerFor } from 'global-logger-factory'; import type { Credentials } from '../../authentication/Credentials'; import type { CredentialsExtractor } from '../../authentication/CredentialsExtractor'; import type { Authorizer } from '../../authorization/Authorizer'; @@ -5,7 +6,6 @@ import type { PermissionReader } from '../../authorization/PermissionReader'; import { OkResponseDescription } from '../../http/output/response/OkResponseDescription'; import type { ResponseDescription } from '../../http/output/response/ResponseDescription'; import { BasicRepresentation } from '../../http/representation/BasicRepresentation'; -import { getLoggerFor } from '../../logging/LogUtil'; import type { RepresentationConverter } from '../../storage/conversion/RepresentationConverter'; import { APPLICATION_LD_JSON, INTERNAL_QUADS } from '../../util/ContentTypes'; import { createErrorMessage } from '../../util/errors/ErrorUtil'; diff --git a/src/server/notifications/NotificationUnsubscriber.ts b/src/server/notifications/NotificationUnsubscriber.ts index 7d2dfd296..a8b526dd9 100644 --- a/src/server/notifications/NotificationUnsubscriber.ts +++ b/src/server/notifications/NotificationUnsubscriber.ts @@ -1,6 +1,6 @@ +import { getLoggerFor } from 'global-logger-factory'; import { ResetResponseDescription } from '../../http/output/response/ResetResponseDescription'; import type { ResponseDescription } from '../../http/output/response/ResponseDescription'; -import { getLoggerFor } from '../../logging/LogUtil'; import { NotFoundHttpError } from '../../util/errors/NotFoundHttpError'; import type { OperationHttpHandlerInput } from '../OperationHttpHandler'; import { OperationHttpHandler } from '../OperationHttpHandler'; diff --git a/src/server/notifications/StreamingHttpChannel2023/StreamingHttp2023Emitter.ts b/src/server/notifications/StreamingHttpChannel2023/StreamingHttp2023Emitter.ts index 8b0c541ca..c758dfb32 100644 --- a/src/server/notifications/StreamingHttpChannel2023/StreamingHttp2023Emitter.ts +++ b/src/server/notifications/StreamingHttpChannel2023/StreamingHttp2023Emitter.ts @@ -1,4 +1,4 @@ -import { getLoggerFor } from '../../../logging/LogUtil'; +import { getLoggerFor } from 'global-logger-factory'; import type { Representation } from '../../../http/representation/Representation'; import { AsyncHandler } from '../../../util/handlers/AsyncHandler'; import { readableToString } from '../../../util/StreamUtil'; diff --git a/src/server/notifications/StreamingHttpChannel2023/StreamingHttpListeningActivityHandler.ts b/src/server/notifications/StreamingHttpChannel2023/StreamingHttpListeningActivityHandler.ts index 693b9dad4..61304a7b1 100644 --- a/src/server/notifications/StreamingHttpChannel2023/StreamingHttpListeningActivityHandler.ts +++ b/src/server/notifications/StreamingHttpChannel2023/StreamingHttpListeningActivityHandler.ts @@ -1,6 +1,6 @@ +import { getLoggerFor } from 'global-logger-factory'; import type { RepresentationMetadata } from '../../../http/representation/RepresentationMetadata'; import type { ResourceIdentifier } from '../../../http/representation/ResourceIdentifier'; -import { getLoggerFor } from '../../../logging/LogUtil'; import { createErrorMessage } from '../../../util/errors/ErrorUtil'; import { StaticHandler } from '../../../util/handlers/StaticHandler'; import type { AS, VocabularyTerm } from '../../../util/Vocabularies'; diff --git a/src/server/notifications/StreamingHttpChannel2023/StreamingHttpMetadataWriter.ts b/src/server/notifications/StreamingHttpChannel2023/StreamingHttpMetadataWriter.ts index 7c88c4a20..0e4055983 100644 --- a/src/server/notifications/StreamingHttpChannel2023/StreamingHttpMetadataWriter.ts +++ b/src/server/notifications/StreamingHttpChannel2023/StreamingHttpMetadataWriter.ts @@ -1,4 +1,4 @@ -import { getLoggerFor } from '../../../logging/LogUtil'; +import { getLoggerFor } from 'global-logger-factory'; import type { HttpResponse } from '../../HttpResponse'; import { addHeader } from '../../../util/HeaderUtil'; import { joinUrl } from '../../../util/PathUtil'; diff --git a/src/server/notifications/StreamingHttpChannel2023/StreamingHttpRequestHandler.ts b/src/server/notifications/StreamingHttpChannel2023/StreamingHttpRequestHandler.ts index 0169ef5e3..2b3bbc68d 100644 --- a/src/server/notifications/StreamingHttpChannel2023/StreamingHttpRequestHandler.ts +++ b/src/server/notifications/StreamingHttpChannel2023/StreamingHttpRequestHandler.ts @@ -1,4 +1,5 @@ import { PassThrough } from 'node:stream'; +import { getLoggerFor } from 'global-logger-factory'; import type { Credentials } from '../../../authentication/Credentials'; import type { CredentialsExtractor } from '../../../authentication/CredentialsExtractor'; import type { Authorizer } from '../../../authorization/Authorizer'; @@ -8,7 +9,6 @@ import { OkResponseDescription } from '../../../http/output/response/OkResponseD import type { ResponseDescription } from '../../../http/output/response/ResponseDescription'; import { BasicRepresentation } from '../../../http/representation/BasicRepresentation'; import type { InteractionRoute } from '../../../identity/interaction/routing/InteractionRoute'; -import { getLoggerFor } from '../../../logging/LogUtil'; import type { OperationHttpHandlerInput } from '../../OperationHttpHandler'; import { OperationHttpHandler } from '../../OperationHttpHandler'; import { guardStream } from '../../../util/GuardedStream'; diff --git a/src/server/notifications/WebSocketChannel2023/WebSocket2023Emitter.ts b/src/server/notifications/WebSocketChannel2023/WebSocket2023Emitter.ts index af2e8f251..c95b71ed1 100644 --- a/src/server/notifications/WebSocketChannel2023/WebSocket2023Emitter.ts +++ b/src/server/notifications/WebSocketChannel2023/WebSocket2023Emitter.ts @@ -1,5 +1,5 @@ import type { WebSocket } from 'ws'; -import { getLoggerFor } from '../../../logging/LogUtil'; +import { getLoggerFor } from 'global-logger-factory'; import type { SetMultiMap } from '../../../util/map/SetMultiMap'; import { readableToString } from '../../../util/StreamUtil'; import { NotificationEmitter } from '../NotificationEmitter'; diff --git a/src/server/notifications/WebSocketChannel2023/WebSocket2023Listener.ts b/src/server/notifications/WebSocketChannel2023/WebSocket2023Listener.ts index 34a5dbaae..f67331c7b 100644 --- a/src/server/notifications/WebSocketChannel2023/WebSocket2023Listener.ts +++ b/src/server/notifications/WebSocketChannel2023/WebSocket2023Listener.ts @@ -1,4 +1,4 @@ -import { getLoggerFor } from '../../../logging/LogUtil'; +import { getLoggerFor } from 'global-logger-factory'; import { NotImplementedHttpError } from '../../../util/errors/NotImplementedHttpError'; import type { WebSocketHandlerInput } from '../../WebSocketHandler'; import { WebSocketHandler } from '../../WebSocketHandler'; diff --git a/src/server/notifications/WebSocketChannel2023/WebSocket2023Storer.ts b/src/server/notifications/WebSocketChannel2023/WebSocket2023Storer.ts index e206041f9..91919bc1f 100644 --- a/src/server/notifications/WebSocketChannel2023/WebSocket2023Storer.ts +++ b/src/server/notifications/WebSocketChannel2023/WebSocket2023Storer.ts @@ -1,5 +1,5 @@ import type { WebSocket } from 'ws'; -import { getLoggerFor } from '../../../logging/LogUtil'; +import { getLoggerFor } from 'global-logger-factory'; import type { SetMultiMap } from '../../../util/map/SetMultiMap'; import { setSafeInterval } from '../../../util/TimerUtil'; import type { NotificationChannelStorage } from '../NotificationChannelStorage'; diff --git a/src/server/notifications/WebSocketChannel2023/WebSocketChannel2023Type.ts b/src/server/notifications/WebSocketChannel2023/WebSocketChannel2023Type.ts index 907961e31..7e55ad433 100644 --- a/src/server/notifications/WebSocketChannel2023/WebSocketChannel2023Type.ts +++ b/src/server/notifications/WebSocketChannel2023/WebSocketChannel2023Type.ts @@ -1,7 +1,7 @@ import type { Store } from 'n3'; +import { getLoggerFor } from 'global-logger-factory'; import type { Credentials } from '../../../authentication/Credentials'; import type { InteractionRoute } from '../../../identity/interaction/routing/InteractionRoute'; -import { getLoggerFor } from '../../../logging/LogUtil'; import { NOTIFY } from '../../../util/Vocabularies'; import { BaseChannelType } from '../BaseChannelType'; import type { NotificationChannel } from '../NotificationChannel'; diff --git a/src/server/notifications/WebhookChannel2023/WebhookChannel2023Type.ts b/src/server/notifications/WebhookChannel2023/WebhookChannel2023Type.ts index 39ffab441..e5f37631f 100644 --- a/src/server/notifications/WebhookChannel2023/WebhookChannel2023Type.ts +++ b/src/server/notifications/WebhookChannel2023/WebhookChannel2023Type.ts @@ -1,6 +1,6 @@ import type { Store } from 'n3'; +import { getLoggerFor } from 'global-logger-factory'; import type { InteractionRoute } from '../../../identity/interaction/routing/InteractionRoute'; -import { getLoggerFor } from '../../../logging/LogUtil'; import { createErrorMessage } from '../../../util/errors/ErrorUtil'; import { NOTIFY } from '../../../util/Vocabularies'; import { BaseChannelType } from '../BaseChannelType'; diff --git a/src/server/notifications/WebhookChannel2023/WebhookEmitter.ts b/src/server/notifications/WebhookChannel2023/WebhookEmitter.ts index a924402ce..8b8d20d6d 100644 --- a/src/server/notifications/WebhookChannel2023/WebhookEmitter.ts +++ b/src/server/notifications/WebhookChannel2023/WebhookEmitter.ts @@ -1,9 +1,9 @@ import fetch from 'cross-fetch'; import { calculateJwkThumbprint, importJWK, SignJWT } from 'jose'; import { v4 } from 'uuid'; +import { getLoggerFor } from 'global-logger-factory'; import type { JwkGenerator } from '../../../identity/configuration/JwkGenerator'; import type { InteractionRoute } from '../../../identity/interaction/routing/InteractionRoute'; -import { getLoggerFor } from '../../../logging/LogUtil'; import { NotImplementedHttpError } from '../../../util/errors/NotImplementedHttpError'; import { trimTrailingSlashes } from '../../../util/PathUtil'; import { readableToString } from '../../../util/StreamUtil'; diff --git a/src/server/util/RedirectingHttpHandler.ts b/src/server/util/RedirectingHttpHandler.ts index 4cafd6473..998c610f8 100644 --- a/src/server/util/RedirectingHttpHandler.ts +++ b/src/server/util/RedirectingHttpHandler.ts @@ -1,7 +1,7 @@ +import { getLoggerFor } from 'global-logger-factory'; import type { TargetExtractor } from '../../http/input/identifier/TargetExtractor'; import { RedirectResponseDescription } from '../../http/output/response/RedirectResponseDescription'; import type { ResponseWriter } from '../../http/output/ResponseWriter'; -import { getLoggerFor } from '../../logging/LogUtil'; import { FoundHttpError } from '../../util/errors/FoundHttpError'; import { MovedPermanentlyHttpError } from '../../util/errors/MovedPermanentlyHttpError'; import { NotImplementedHttpError } from '../../util/errors/NotImplementedHttpError'; diff --git a/src/storage/BinarySliceResourceStore.ts b/src/storage/BinarySliceResourceStore.ts index 4c33bc6eb..21b5e0353 100644 --- a/src/storage/BinarySliceResourceStore.ts +++ b/src/storage/BinarySliceResourceStore.ts @@ -1,7 +1,7 @@ +import { getLoggerFor } from 'global-logger-factory'; import type { Representation } from '../http/representation/Representation'; import type { RepresentationPreferences } from '../http/representation/RepresentationPreferences'; import type { ResourceIdentifier } from '../http/representation/ResourceIdentifier'; -import { getLoggerFor } from '../logging/LogUtil'; import { InternalServerError } from '../util/errors/InternalServerError'; import { RangeNotSatisfiedHttpError } from '../util/errors/RangeNotSatisfiedHttpError'; import { guardStream } from '../util/GuardedStream'; diff --git a/src/storage/DataAccessorBasedStore.ts b/src/storage/DataAccessorBasedStore.ts index b68fa2552..f5b0fe9bd 100644 --- a/src/storage/DataAccessorBasedStore.ts +++ b/src/storage/DataAccessorBasedStore.ts @@ -2,13 +2,13 @@ import type { NamedNode, Quad, Term } from '@rdfjs/types'; import arrayifyStream from 'arrayify-stream'; import { DataFactory } from 'n3'; import { v4 as uuid } from 'uuid'; +import { getLoggerFor } from 'global-logger-factory'; import type { AuxiliaryStrategy } from '../http/auxiliary/AuxiliaryStrategy'; import { BasicRepresentation } from '../http/representation/BasicRepresentation'; import type { Patch } from '../http/representation/Patch'; import type { Representation } from '../http/representation/Representation'; import { RepresentationMetadata } from '../http/representation/RepresentationMetadata'; import type { ResourceIdentifier } from '../http/representation/ResourceIdentifier'; -import { getLoggerFor } from '../logging/LogUtil'; import { INTERNAL_QUADS } from '../util/ContentTypes'; import { BadRequestHttpError } from '../util/errors/BadRequestHttpError'; import { ConflictHttpError } from '../util/errors/ConflictHttpError'; diff --git a/src/storage/LockingResourceStore.ts b/src/storage/LockingResourceStore.ts index 562c605c5..a635dd989 100644 --- a/src/storage/LockingResourceStore.ts +++ b/src/storage/LockingResourceStore.ts @@ -1,11 +1,11 @@ import type { Readable } from 'node:stream'; +import { getLoggerFor } from 'global-logger-factory'; import type { AuxiliaryIdentifierStrategy } from '../http/auxiliary/AuxiliaryIdentifierStrategy'; import { BasicRepresentation } from '../http/representation/BasicRepresentation'; import type { Patch } from '../http/representation/Patch'; import type { Representation } from '../http/representation/Representation'; import type { RepresentationPreferences } from '../http/representation/RepresentationPreferences'; import type { ResourceIdentifier } from '../http/representation/ResourceIdentifier'; -import { getLoggerFor } from '../logging/LogUtil'; import type { ExpiringReadWriteLocker } from '../util/locking/ExpiringReadWriteLocker'; import { endOfStream } from '../util/StreamUtil'; import type { AtomicResourceStore } from './AtomicResourceStore'; diff --git a/src/storage/RepresentationConvertingStore.ts b/src/storage/RepresentationConvertingStore.ts index 4675fa4a7..4b10423e8 100644 --- a/src/storage/RepresentationConvertingStore.ts +++ b/src/storage/RepresentationConvertingStore.ts @@ -1,8 +1,8 @@ +import { getLoggerFor } from 'global-logger-factory'; import type { AuxiliaryStrategy } from '../http/auxiliary/AuxiliaryStrategy'; import type { Representation } from '../http/representation/Representation'; import type { RepresentationPreferences } from '../http/representation/RepresentationPreferences'; import type { ResourceIdentifier } from '../http/representation/ResourceIdentifier'; -import { getLoggerFor } from '../logging/LogUtil'; import { INTERNAL_QUADS } from '../util/ContentTypes'; import type { Conditions } from './conditions/Conditions'; import { PassthroughConverter } from './conversion/PassthroughConverter'; diff --git a/src/storage/accessors/FileDataAccessor.ts b/src/storage/accessors/FileDataAccessor.ts index a9caefcef..b7e5f2537 100644 --- a/src/storage/accessors/FileDataAccessor.ts +++ b/src/storage/accessors/FileDataAccessor.ts @@ -2,10 +2,10 @@ import type { Readable } from 'node:stream'; import type { Stats } from 'fs-extra'; import { createReadStream, createWriteStream, ensureDir, lstat, opendir, remove, stat } from 'fs-extra'; import type { Quad } from '@rdfjs/types'; +import { getLoggerFor } from 'global-logger-factory'; import type { Representation } from '../../http/representation/Representation'; import { RepresentationMetadata } from '../../http/representation/RepresentationMetadata'; import type { ResourceIdentifier } from '../../http/representation/ResourceIdentifier'; -import { getLoggerFor } from '../../logging/LogUtil'; import { NotFoundHttpError } from '../../util/errors/NotFoundHttpError'; import { isSystemError } from '../../util/errors/SystemError'; import { UnsupportedMediaTypeHttpError } from '../../util/errors/UnsupportedMediaTypeHttpError'; diff --git a/src/storage/accessors/SparqlDataAccessor.ts b/src/storage/accessors/SparqlDataAccessor.ts index 7eef80963..f9c692e2f 100644 --- a/src/storage/accessors/SparqlDataAccessor.ts +++ b/src/storage/accessors/SparqlDataAccessor.ts @@ -13,10 +13,10 @@ import type { UpdateOperation, } from 'sparqljs'; import { Generator } from 'sparqljs'; +import { getLoggerFor } from 'global-logger-factory'; import type { Representation } from '../../http/representation/Representation'; import { RepresentationMetadata } from '../../http/representation/RepresentationMetadata'; import type { ResourceIdentifier } from '../../http/representation/ResourceIdentifier'; -import { getLoggerFor } from '../../logging/LogUtil'; import { INTERNAL_QUADS } from '../../util/ContentTypes'; import { ConflictHttpError } from '../../util/errors/ConflictHttpError'; import { createErrorMessage } from '../../util/errors/ErrorUtil'; diff --git a/src/storage/conversion/ChainedConverter.ts b/src/storage/conversion/ChainedConverter.ts index 5bcc8c4cc..d36b27bde 100644 --- a/src/storage/conversion/ChainedConverter.ts +++ b/src/storage/conversion/ChainedConverter.ts @@ -1,8 +1,8 @@ +import { getLoggerFor } from 'global-logger-factory'; import { BasicRepresentation } from '../../http/representation/BasicRepresentation'; import type { Representation } from '../../http/representation/Representation'; import { RepresentationMetadata } from '../../http/representation/RepresentationMetadata'; import type { ValuePreferences } from '../../http/representation/RepresentationPreferences'; -import { getLoggerFor } from '../../logging/LogUtil'; import { BadRequestHttpError } from '../../util/errors/BadRequestHttpError'; import { NotImplementedHttpError } from '../../util/errors/NotImplementedHttpError'; import { POSIX } from '../../util/Vocabularies'; diff --git a/src/storage/conversion/ConstantConverter.ts b/src/storage/conversion/ConstantConverter.ts index a19cce4be..717dcb654 100644 --- a/src/storage/conversion/ConstantConverter.ts +++ b/src/storage/conversion/ConstantConverter.ts @@ -1,9 +1,9 @@ import type { Stats } from 'node:fs'; import { createReadStream } from 'node:fs'; import { stat } from 'fs-extra'; +import { getLoggerFor } from 'global-logger-factory'; import { BasicRepresentation } from '../../http/representation/BasicRepresentation'; import type { Representation } from '../../http/representation/Representation'; -import { getLoggerFor } from '../../logging/LogUtil'; import { createErrorMessage } from '../../util/errors/ErrorUtil'; import { InternalServerError } from '../../util/errors/InternalServerError'; import { NotImplementedHttpError } from '../../util/errors/NotImplementedHttpError'; diff --git a/src/storage/keyvalue/HashEncodingStorage.ts b/src/storage/keyvalue/HashEncodingStorage.ts index 016e1edb5..f50856377 100644 --- a/src/storage/keyvalue/HashEncodingStorage.ts +++ b/src/storage/keyvalue/HashEncodingStorage.ts @@ -1,5 +1,5 @@ import { createHash } from 'node:crypto'; -import { getLoggerFor } from '../../logging/LogUtil'; +import { getLoggerFor } from 'global-logger-factory'; import { NotImplementedHttpError } from '../../util/errors/NotImplementedHttpError'; import type { KeyValueStorage } from './KeyValueStorage'; import { PassthroughKeyValueStorage } from './PassthroughKeyValueStorage'; diff --git a/src/storage/keyvalue/JsonResourceStorage.ts b/src/storage/keyvalue/JsonResourceStorage.ts index 43fa2773c..4876832df 100644 --- a/src/storage/keyvalue/JsonResourceStorage.ts +++ b/src/storage/keyvalue/JsonResourceStorage.ts @@ -1,7 +1,7 @@ +import { getLoggerFor } from 'global-logger-factory'; import { BasicRepresentation } from '../../http/representation/BasicRepresentation'; import type { Representation } from '../../http/representation/Representation'; import type { ResourceIdentifier } from '../../http/representation/ResourceIdentifier'; -import { getLoggerFor } from '../../logging/LogUtil'; import { createErrorMessage } from '../../util/errors/ErrorUtil'; import { NotFoundHttpError } from '../../util/errors/NotFoundHttpError'; import { ensureTrailingSlash, isContainerIdentifier, joinUrl, trimLeadingSlashes } from '../../util/PathUtil'; diff --git a/src/storage/keyvalue/MaxKeyLengthStorage.ts b/src/storage/keyvalue/MaxKeyLengthStorage.ts index e30c44092..9c731419d 100644 --- a/src/storage/keyvalue/MaxKeyLengthStorage.ts +++ b/src/storage/keyvalue/MaxKeyLengthStorage.ts @@ -1,5 +1,5 @@ import { createHash } from 'node:crypto'; -import { getLoggerFor } from '../../logging/LogUtil'; +import { getLoggerFor } from 'global-logger-factory'; import { NotImplementedHttpError } from '../../util/errors/NotImplementedHttpError'; import type { KeyValueStorage } from './KeyValueStorage'; diff --git a/src/storage/keyvalue/WrappedExpiringStorage.ts b/src/storage/keyvalue/WrappedExpiringStorage.ts index d35c3d7c9..bd196f4c6 100644 --- a/src/storage/keyvalue/WrappedExpiringStorage.ts +++ b/src/storage/keyvalue/WrappedExpiringStorage.ts @@ -1,4 +1,4 @@ -import { getLoggerFor } from '../../logging/LogUtil'; +import { getLoggerFor } from 'global-logger-factory'; import { InternalServerError } from '../../util/errors/InternalServerError'; import { setSafeInterval } from '../../util/TimerUtil'; import type { ExpiringStorage } from './ExpiringStorage'; diff --git a/src/storage/keyvalue/WrappedIndexedStorage.ts b/src/storage/keyvalue/WrappedIndexedStorage.ts index b2fefb47b..b5822ba7a 100644 --- a/src/storage/keyvalue/WrappedIndexedStorage.ts +++ b/src/storage/keyvalue/WrappedIndexedStorage.ts @@ -1,5 +1,5 @@ import { v4 } from 'uuid'; -import { getLoggerFor } from '../../logging/LogUtil'; +import { getLoggerFor } from 'global-logger-factory'; import { InternalServerError } from '../../util/errors/InternalServerError'; import { NotFoundHttpError } from '../../util/errors/NotFoundHttpError'; import { NotImplementedHttpError } from '../../util/errors/NotImplementedHttpError'; diff --git a/src/storage/mapping/BaseFileIdentifierMapper.ts b/src/storage/mapping/BaseFileIdentifierMapper.ts index 001befaf0..9446a3a6a 100644 --- a/src/storage/mapping/BaseFileIdentifierMapper.ts +++ b/src/storage/mapping/BaseFileIdentifierMapper.ts @@ -1,5 +1,5 @@ +import { getLoggerFor } from 'global-logger-factory'; import type { ResourceIdentifier } from '../../http/representation/ResourceIdentifier'; -import { getLoggerFor } from '../../logging/LogUtil'; import { APPLICATION_OCTET_STREAM } from '../../util/ContentTypes'; import { BadRequestHttpError } from '../../util/errors/BadRequestHttpError'; import { InternalServerError } from '../../util/errors/InternalServerError'; diff --git a/src/storage/patch/ConvertingPatcher.ts b/src/storage/patch/ConvertingPatcher.ts index e24f664fc..0aed8413f 100644 --- a/src/storage/patch/ConvertingPatcher.ts +++ b/src/storage/patch/ConvertingPatcher.ts @@ -1,6 +1,6 @@ +import { getLoggerFor } from 'global-logger-factory'; import { BasicRepresentation } from '../../http/representation/BasicRepresentation'; import type { Representation } from '../../http/representation/Representation'; -import { getLoggerFor } from '../../logging/LogUtil'; import type { RepresentationConverter } from '../conversion/RepresentationConverter'; import type { RepresentationPatcherInput } from './RepresentationPatcher'; import { RepresentationPatcher } from './RepresentationPatcher'; diff --git a/src/storage/patch/ImmutableMetadataPatcher.ts b/src/storage/patch/ImmutableMetadataPatcher.ts index 8475be95f..c525ea6c1 100644 --- a/src/storage/patch/ImmutableMetadataPatcher.ts +++ b/src/storage/patch/ImmutableMetadataPatcher.ts @@ -1,8 +1,8 @@ import { DataFactory } from 'n3'; import type { Quad } from '@rdfjs/types'; +import { getLoggerFor } from 'global-logger-factory'; import type { AuxiliaryStrategy } from '../../http/auxiliary/AuxiliaryStrategy'; import type { RdfDatasetRepresentation } from '../../http/representation/RdfDatasetRepresentation'; -import { getLoggerFor } from '../../logging/LogUtil'; import { ConflictHttpError } from '../../util/errors/ConflictHttpError'; import { InternalServerError } from '../../util/errors/InternalServerError'; import { NotImplementedHttpError } from '../../util/errors/NotImplementedHttpError'; diff --git a/src/storage/patch/N3Patcher.ts b/src/storage/patch/N3Patcher.ts index f04bee784..92eac8d9a 100644 --- a/src/storage/patch/N3Patcher.ts +++ b/src/storage/patch/N3Patcher.ts @@ -5,11 +5,11 @@ import type { Bindings, Quad, Term } from '@rdfjs/types'; import { mapTerms } from 'rdf-terms'; import { Generator, Wildcard } from 'sparqljs'; import type { SparqlGenerator } from 'sparqljs'; +import { getLoggerFor } from 'global-logger-factory'; import { isN3Patch } from '../../http/representation/N3Patch'; import type { N3Patch } from '../../http/representation/N3Patch'; import type { RdfDatasetRepresentation } from '../../http/representation/RdfDatasetRepresentation'; import type { ResourceIdentifier } from '../../http/representation/ResourceIdentifier'; -import { getLoggerFor } from '../../logging/LogUtil'; import { ConflictHttpError } from '../../util/errors/ConflictHttpError'; import { InternalServerError } from '../../util/errors/InternalServerError'; import { NotImplementedHttpError } from '../../util/errors/NotImplementedHttpError'; diff --git a/src/storage/patch/RdfPatcher.ts b/src/storage/patch/RdfPatcher.ts index c933c19e5..804da4c4e 100644 --- a/src/storage/patch/RdfPatcher.ts +++ b/src/storage/patch/RdfPatcher.ts @@ -1,10 +1,10 @@ import type { Readable } from 'node:stream'; import { Store } from 'n3'; +import { getLoggerFor } from 'global-logger-factory'; import { BasicRepresentation } from '../../http/representation/BasicRepresentation'; import type { RdfDatasetRepresentation } from '../../http/representation/RdfDatasetRepresentation'; import type { Representation } from '../../http/representation/Representation'; import { RepresentationMetadata } from '../../http/representation/RepresentationMetadata'; -import { getLoggerFor } from '../../logging/LogUtil'; import { INTERNAL_QUADS } from '../../util/ContentTypes'; import { InternalServerError } from '../../util/errors/InternalServerError'; import { readableToQuads } from '../../util/StreamUtil'; diff --git a/src/storage/patch/RepresentationPatchHandler.ts b/src/storage/patch/RepresentationPatchHandler.ts index 48569129c..2dd886309 100644 --- a/src/storage/patch/RepresentationPatchHandler.ts +++ b/src/storage/patch/RepresentationPatchHandler.ts @@ -1,5 +1,5 @@ +import { getLoggerFor } from 'global-logger-factory'; import type { Representation } from '../../http/representation/Representation'; -import { getLoggerFor } from '../../logging/LogUtil'; import { INTERNAL_ALL } from '../../util/ContentTypes'; import { ConflictHttpError } from '../../util/errors/ConflictHttpError'; import { NotFoundHttpError } from '../../util/errors/NotFoundHttpError'; diff --git a/src/storage/patch/SparqlUpdatePatcher.ts b/src/storage/patch/SparqlUpdatePatcher.ts index 80624b97d..db50f2c13 100644 --- a/src/storage/patch/SparqlUpdatePatcher.ts +++ b/src/storage/patch/SparqlUpdatePatcher.ts @@ -2,10 +2,10 @@ import { QueryEngine } from '@comunica/query-sparql'; import type { Store } from 'n3'; import { DataFactory } from 'n3'; import { Algebra } from 'sparqlalgebrajs'; +import { getLoggerFor } from 'global-logger-factory'; import type { Patch } from '../../http/representation/Patch'; import type { RdfDatasetRepresentation } from '../../http/representation/RdfDatasetRepresentation'; import type { SparqlUpdatePatch } from '../../http/representation/SparqlUpdatePatch'; -import { getLoggerFor } from '../../logging/LogUtil'; import { InternalServerError } from '../../util/errors/InternalServerError'; import { NotImplementedHttpError } from '../../util/errors/NotImplementedHttpError'; import { readableToString } from '../../util/StreamUtil'; diff --git a/src/util/FetchUtil.ts b/src/util/FetchUtil.ts index 699069e26..32d6012e3 100644 --- a/src/util/FetchUtil.ts +++ b/src/util/FetchUtil.ts @@ -2,9 +2,9 @@ import type { Quad } from '@rdfjs/types'; import arrayifyStream from 'arrayify-stream'; import type { Response } from 'cross-fetch'; import rdfDereferencer from 'rdf-dereference'; +import { getLoggerFor } from 'global-logger-factory'; import { BasicRepresentation } from '../http/representation/BasicRepresentation'; import type { Representation } from '../http/representation/Representation'; -import { getLoggerFor } from '../logging/LogUtil'; import type { RepresentationConverter } from '../storage/conversion/RepresentationConverter'; import { INTERNAL_QUADS } from './ContentTypes'; import { BadRequestHttpError } from './errors/BadRequestHttpError'; diff --git a/src/util/GuardedStream.ts b/src/util/GuardedStream.ts index a659bffd9..49e985cd4 100644 --- a/src/util/GuardedStream.ts +++ b/src/util/GuardedStream.ts @@ -1,4 +1,4 @@ -import { getLoggerFor } from '../logging/LogUtil'; +import { getLoggerFor } from 'global-logger-factory'; const logger = getLoggerFor('GuardedStream'); diff --git a/src/util/HeaderUtil.ts b/src/util/HeaderUtil.ts index ceddab8af..0f4fe9b52 100644 --- a/src/util/HeaderUtil.ts +++ b/src/util/HeaderUtil.ts @@ -1,6 +1,6 @@ import type { IncomingHttpHeaders } from 'node:http'; import escapeStringRegexp from 'escape-string-regexp'; -import { getLoggerFor } from '../logging/LogUtil'; +import { getLoggerFor } from 'global-logger-factory'; import type { HttpResponse } from '../server/HttpResponse'; import { BadRequestHttpError } from './errors/BadRequestHttpError'; import type { diff --git a/src/util/LockUtils.ts b/src/util/LockUtils.ts index d363ff245..c64d89cf5 100644 --- a/src/util/LockUtils.ts +++ b/src/util/LockUtils.ts @@ -1,4 +1,4 @@ -import { getLoggerFor } from '../logging/LogUtil'; +import { getLoggerFor } from 'global-logger-factory'; import { InternalServerError } from './errors/InternalServerError'; const logger = getLoggerFor('LockUtil'); diff --git a/src/util/StreamUtil.ts b/src/util/StreamUtil.ts index 5bb7830fc..d5e80fd7e 100644 --- a/src/util/StreamUtil.ts +++ b/src/util/StreamUtil.ts @@ -5,7 +5,7 @@ import arrayifyStream from 'arrayify-stream'; import eos from 'end-of-stream'; import { Store } from 'n3'; import pump from 'pump'; -import { getLoggerFor } from '../logging/LogUtil'; +import { getLoggerFor } from 'global-logger-factory'; import { isHttpRequest } from '../server/HttpRequest'; import { InternalServerError } from './errors/InternalServerError'; import type { Guarded } from './GuardedStream'; diff --git a/src/util/TimerUtil.ts b/src/util/TimerUtil.ts index 1fb6a78f7..08ae9da57 100644 --- a/src/util/TimerUtil.ts +++ b/src/util/TimerUtil.ts @@ -1,4 +1,4 @@ -import type { Logger } from '../logging/Logger'; +import type { Logger } from 'global-logger-factory'; import { createErrorMessage } from './errors/ErrorUtil'; /** diff --git a/src/util/handlers/BooleanHandler.ts b/src/util/handlers/BooleanHandler.ts index acc5cffd1..29d3a9f87 100644 --- a/src/util/handlers/BooleanHandler.ts +++ b/src/util/handlers/BooleanHandler.ts @@ -1,4 +1,4 @@ -import { getLoggerFor } from '../../logging/LogUtil'; +import { getLoggerFor } from 'global-logger-factory'; import { InternalServerError } from '../errors/InternalServerError'; import { promiseSome } from '../PromiseUtil'; import { AsyncHandler } from './AsyncHandler'; diff --git a/src/util/handlers/WaterfallHandler.ts b/src/util/handlers/WaterfallHandler.ts index 229951aee..2d5271c90 100644 --- a/src/util/handlers/WaterfallHandler.ts +++ b/src/util/handlers/WaterfallHandler.ts @@ -1,4 +1,4 @@ -import { getLoggerFor } from '../../logging/LogUtil'; +import { getLoggerFor } from 'global-logger-factory'; import { InternalServerError } from '../errors/InternalServerError'; import type { AsyncHandler } from './AsyncHandler'; import { findHandler } from './HandlerUtil'; diff --git a/src/util/identifiers/SingleRootIdentifierStrategy.ts b/src/util/identifiers/SingleRootIdentifierStrategy.ts index ee1e9013e..c933907b7 100644 --- a/src/util/identifiers/SingleRootIdentifierStrategy.ts +++ b/src/util/identifiers/SingleRootIdentifierStrategy.ts @@ -1,5 +1,5 @@ +import { getLoggerFor } from 'global-logger-factory'; import type { ResourceIdentifier } from '../../http/representation/ResourceIdentifier'; -import { getLoggerFor } from '../../logging/LogUtil'; import { ensureTrailingSlash } from '../PathUtil'; import { BaseIdentifierStrategy } from './BaseIdentifierStrategy'; diff --git a/src/util/identifiers/SubdomainIdentifierStrategy.ts b/src/util/identifiers/SubdomainIdentifierStrategy.ts index f87f9b95e..5d7cfb306 100644 --- a/src/util/identifiers/SubdomainIdentifierStrategy.ts +++ b/src/util/identifiers/SubdomainIdentifierStrategy.ts @@ -1,5 +1,5 @@ +import { getLoggerFor } from 'global-logger-factory'; import type { ResourceIdentifier } from '../../http/representation/ResourceIdentifier'; -import { getLoggerFor } from '../../logging/LogUtil'; import { createSubdomainRegexp, ensureTrailingSlash } from '../PathUtil'; import { BaseIdentifierStrategy } from './BaseIdentifierStrategy'; diff --git a/src/util/locking/FileSystemResourceLocker.ts b/src/util/locking/FileSystemResourceLocker.ts index 3173ba8cc..daf9a3082 100644 --- a/src/util/locking/FileSystemResourceLocker.ts +++ b/src/util/locking/FileSystemResourceLocker.ts @@ -2,10 +2,10 @@ import { createHash } from 'node:crypto'; import { ensureDir, remove } from 'fs-extra'; import type { LockOptions, UnlockOptions } from 'proper-lockfile'; import { lock, unlock } from 'proper-lockfile'; +import { getLoggerFor } from 'global-logger-factory'; import type { ResourceIdentifier } from '../../http/representation/ResourceIdentifier'; import type { Finalizable } from '../../init/final/Finalizable'; import type { Initializable } from '../../init/Initializable'; -import { getLoggerFor } from '../../logging/LogUtil'; import { createErrorMessage } from '../errors/ErrorUtil'; import { InternalServerError } from '../errors/InternalServerError'; import type { AttemptSettings } from '../LockUtils'; diff --git a/src/util/locking/MemoryResourceLocker.ts b/src/util/locking/MemoryResourceLocker.ts index 6e4a69f1d..4b8598af4 100644 --- a/src/util/locking/MemoryResourceLocker.ts +++ b/src/util/locking/MemoryResourceLocker.ts @@ -1,7 +1,7 @@ import AsyncLock from 'async-lock'; +import { getLoggerFor } from 'global-logger-factory'; import type { ResourceIdentifier } from '../../http/representation/ResourceIdentifier'; import type { SingleThreaded } from '../../init/cluster/SingleThreaded'; -import { getLoggerFor } from '../../logging/LogUtil'; import { InternalServerError } from '../errors/InternalServerError'; import type { ResourceLocker } from './ResourceLocker'; diff --git a/src/util/locking/RedisLocker.ts b/src/util/locking/RedisLocker.ts index 377f30b8e..2706d9629 100644 --- a/src/util/locking/RedisLocker.ts +++ b/src/util/locking/RedisLocker.ts @@ -1,8 +1,8 @@ import Redis from 'ioredis'; +import { getLoggerFor } from 'global-logger-factory'; import type { ResourceIdentifier } from '../../http/representation/ResourceIdentifier'; import type { Finalizable } from '../../init/final/Finalizable'; import type { Initializable } from '../../init/Initializable'; -import { getLoggerFor } from '../../logging/LogUtil'; import type { AttemptSettings } from '../LockUtils'; import { retryFunction } from '../LockUtils'; import type { PromiseOrValue } from '../PromiseUtil'; diff --git a/src/util/locking/VoidLocker.ts b/src/util/locking/VoidLocker.ts index ecf2743dd..78b89b03a 100644 --- a/src/util/locking/VoidLocker.ts +++ b/src/util/locking/VoidLocker.ts @@ -1,5 +1,5 @@ +import { getLoggerFor } from 'global-logger-factory'; import type { ResourceIdentifier } from '../../http/representation/ResourceIdentifier'; -import { getLoggerFor } from '../../logging/LogUtil'; import type { PromiseOrValue } from '../PromiseUtil'; import type { ExpiringReadWriteLocker } from './ExpiringReadWriteLocker'; diff --git a/src/util/locking/WrappedExpiringReadWriteLocker.ts b/src/util/locking/WrappedExpiringReadWriteLocker.ts index e5bead275..eede47a42 100644 --- a/src/util/locking/WrappedExpiringReadWriteLocker.ts +++ b/src/util/locking/WrappedExpiringReadWriteLocker.ts @@ -1,5 +1,5 @@ +import { getLoggerFor } from 'global-logger-factory'; import type { ResourceIdentifier } from '../../http/representation/ResourceIdentifier'; -import { getLoggerFor } from '../../logging/LogUtil'; import { InternalServerError } from '../errors/InternalServerError'; import type { PromiseOrValue } from '../PromiseUtil'; import type { ExpiringReadWriteLocker } from './ExpiringReadWriteLocker'; diff --git a/test/integration/GuardedStream.test.ts b/test/integration/GuardedStream.test.ts index 8f02a3a8c..687ac786f 100644 --- a/test/integration/GuardedStream.test.ts +++ b/test/integration/GuardedStream.test.ts @@ -1,17 +1,18 @@ +import type { Logger } from 'global-logger-factory'; +import { getLoggerFor } from 'global-logger-factory'; import { BasicRepresentation, ChainedConverter, - getLoggerFor, guardedStreamFrom, INTERNAL_QUADS, RdfToQuadConverter, readableToString, RepresentationMetadata, } from '../../src'; -import type { Logger, Representation, RepresentationConverterArgs } from '../../src'; +import type { Representation, RepresentationConverterArgs } from '../../src'; import { BaseTypedRepresentationConverter } from '../../src/storage/conversion/BaseTypedRepresentationConverter'; -jest.mock('../../src/logging/LogUtil', (): any => { +jest.mock('global-logger-factory', (): any => { const logger: Logger = { error: jest.fn(), debug: jest.fn(), warn: jest.fn(), info: jest.fn(), log: jest.fn() } as any; return { getLoggerFor: (): Logger => logger }; diff --git a/test/unit/init/BaseUrlVerifier.test.ts b/test/unit/init/BaseUrlVerifier.test.ts index a669caf6a..52334cdb4 100644 --- a/test/unit/init/BaseUrlVerifier.test.ts +++ b/test/unit/init/BaseUrlVerifier.test.ts @@ -1,9 +1,9 @@ +import { getLoggerFor } from 'global-logger-factory'; +import type { Logger } from 'global-logger-factory'; import { BaseUrlVerifier } from '../../../src/init/BaseUrlVerifier'; -import type { Logger } from '../../../src/logging/Logger'; -import { getLoggerFor } from '../../../src/logging/LogUtil'; import type { KeyValueStorage } from '../../../src/storage/keyvalue/KeyValueStorage'; -jest.mock('../../../src/logging/LogUtil', (): any => { +jest.mock('global-logger-factory', (): any => { const logger: Logger = { warn: jest.fn() } as any; return { getLoggerFor: (): Logger => logger }; }); diff --git a/test/unit/init/ContainerInitializer.test.ts b/test/unit/init/ContainerInitializer.test.ts index 9019deb6e..37163a2b8 100644 --- a/test/unit/init/ContainerInitializer.test.ts +++ b/test/unit/init/ContainerInitializer.test.ts @@ -1,11 +1,11 @@ +import { getLoggerFor } from 'global-logger-factory'; +import type { Logger } from 'global-logger-factory'; import { ContainerInitializer } from '../../../src/init/ContainerInitializer'; -import type { Logger } from '../../../src/logging/Logger'; -import { getLoggerFor } from '../../../src/logging/LogUtil'; import type { Resource, ResourcesGenerator } from '../../../src/pods/generate/ResourcesGenerator'; import type { KeyValueStorage } from '../../../src/storage/keyvalue/KeyValueStorage'; import type { ResourceStore } from '../../../src/storage/ResourceStore'; -jest.mock('../../../src/logging/LogUtil', (): any => { +jest.mock('global-logger-factory', (): any => { const logger: Logger = { warn: jest.fn(), debug: jest.fn(), info: jest.fn() } as any; return { getLoggerFor: (): Logger => logger }; }); diff --git a/test/unit/init/LoggerInitializer.test.ts b/test/unit/init/LoggerInitializer.test.ts index ef4d37823..7cce81b1e 100644 --- a/test/unit/init/LoggerInitializer.test.ts +++ b/test/unit/init/LoggerInitializer.test.ts @@ -1,8 +1,8 @@ +import type { LoggerFactory } from 'global-logger-factory'; +import { setGlobalLoggerFactory } from 'global-logger-factory'; import { LoggerInitializer } from '../../../src/init/LoggerInitializer'; -import type { LoggerFactory } from '../../../src/logging/LoggerFactory'; -import { setGlobalLoggerFactory } from '../../../src/logging/LogUtil'; -jest.mock('../../../src/logging/LogUtil'); +jest.mock('global-logger-factory'); describe('LoggerInitializer', (): void => { const loggerFactory = {} as LoggerFactory; diff --git a/test/unit/init/ServerInitializer.test.ts b/test/unit/init/ServerInitializer.test.ts index 5c16704b3..b51d22771 100644 --- a/test/unit/init/ServerInitializer.test.ts +++ b/test/unit/init/ServerInitializer.test.ts @@ -1,13 +1,13 @@ import type { Server } from 'node:http'; import { Server as HttpsServer } from 'node:https'; +import { getLoggerFor } from 'global-logger-factory'; +import type { Logger } from 'global-logger-factory'; import { ServerInitializer } from '../../../src/init/ServerInitializer'; -import type { Logger } from '../../../src/logging/Logger'; -import { getLoggerFor } from '../../../src/logging/LogUtil'; import type { HttpServerFactory } from '../../../src/server/HttpServerFactory'; // Mock so we don't create an actual HTTPS server in the test below jest.mock('node:https'); -jest.mock('../../../src/logging/LogUtil'); +jest.mock('global-logger-factory'); describe('ServerInitializer', (): void => { let logger: jest.Mocked; diff --git a/test/unit/init/cluster/ClusterManager.test.ts b/test/unit/init/cluster/ClusterManager.test.ts index 352f34956..dfb8101c3 100644 --- a/test/unit/init/cluster/ClusterManager.test.ts +++ b/test/unit/init/cluster/ClusterManager.test.ts @@ -1,14 +1,15 @@ import cluster from 'node:cluster'; import EventEmitter from 'node:events'; import { cpus } from 'node:os'; +import * as glf from 'global-logger-factory'; import { ClusterManager } from '../../../../src'; -import * as LogUtil from '../../../../src/logging/LogUtil'; jest.mock('node:cluster'); jest.mock('node:os', (): any => ({ ...jest.requireActual('node:os'), cpus: jest.fn().mockImplementation((): any => [{}, {}, {}, {}, {}, {}]), })); +jest.mock('global-logger-factory'); const mockWorker = new EventEmitter() as any; mockWorker.process = { pid: 666 }; @@ -17,7 +18,7 @@ describe('A ClusterManager', (): void => { const emitter = new EventEmitter(); const mockCluster = jest.requireMock('node:cluster'); const mockLogger = { info: jest.fn(), warn: jest.fn() }; - jest.spyOn(LogUtil, 'getLoggerFor').mockImplementation((): any => mockLogger); + jest.spyOn(glf, 'getLoggerFor').mockImplementation((): any => mockLogger); beforeAll((): void => { Object.assign(mockCluster, { diff --git a/test/unit/logging/LazyLoggerFactory.test.ts b/test/unit/logging/LazyLoggerFactory.test.ts deleted file mode 100644 index a9fec1a95..000000000 --- a/test/unit/logging/LazyLoggerFactory.test.ts +++ /dev/null @@ -1,93 +0,0 @@ -import { LazyLoggerFactory } from '../../../src/logging/LazyLoggerFactory'; -import type { Logger } from '../../../src/logging/Logger'; -import type { LoggerFactory } from '../../../src/logging/LoggerFactory'; - -describe('LazyLoggerFactory', (): void => { - let lazyLoggerFactory: LazyLoggerFactory; - let dummyLoggerFactory: jest.Mocked; - - beforeEach(async(): Promise => { - lazyLoggerFactory = new LazyLoggerFactory(); - dummyLoggerFactory = { - createLogger: jest.fn((): jest.Mocked => ({ - log: jest.fn((): any => null), - }) as any), - } as any; - }); - - it('does not allow reading the internal factory before it is set.', (): void => { - expect((): void => { - expect(lazyLoggerFactory.loggerFactory).toBeNull(); - }).toThrow('Logger factory not yet set.'); - }); - - it('allows setting the internal factory.', (): void => { - lazyLoggerFactory.loggerFactory = dummyLoggerFactory; - expect(lazyLoggerFactory.loggerFactory).toBe(dummyLoggerFactory); - }); - - it('creates loggers with the right labels.', (): void => { - lazyLoggerFactory.createLogger('LoggerA'); - lazyLoggerFactory.createLogger('LoggerB'); - - lazyLoggerFactory.loggerFactory = dummyLoggerFactory; - - expect(dummyLoggerFactory.createLogger).toHaveBeenCalledTimes(2); - expect(dummyLoggerFactory.createLogger).toHaveBeenNthCalledWith(1, 'LoggerA'); - expect(dummyLoggerFactory.createLogger).toHaveBeenNthCalledWith(2, 'LoggerB'); - - lazyLoggerFactory.createLogger('LoggerC'); - expect(dummyLoggerFactory.createLogger).toHaveBeenCalledTimes(3); - expect(dummyLoggerFactory.createLogger).toHaveBeenNthCalledWith(3, 'LoggerC'); - }); - - it('emits logged messages after a logger is set.', (): void => { - const loggerA = lazyLoggerFactory.createLogger('LoggerA'); - const loggerB = lazyLoggerFactory.createLogger('LoggerB'); - loggerA.warn('message1'); - loggerB.warn('message2'); - loggerB.error('message3'); - loggerA.error('message4'); - - lazyLoggerFactory.loggerFactory = dummyLoggerFactory; - - const wrappedA = dummyLoggerFactory.createLogger.mock.results[0].value as jest.Mocked; - expect(wrappedA.log).toHaveBeenCalledTimes(2); - expect(wrappedA.log).toHaveBeenNthCalledWith(1, 'warn', 'message1', expect.any(Object)); - expect(wrappedA.log).toHaveBeenNthCalledWith(2, 'error', 'message4', expect.any(Object)); - - const wrappedB = dummyLoggerFactory.createLogger.mock.results[1].value as jest.Mocked; - expect(wrappedB.log).toHaveBeenCalledTimes(2); - expect(wrappedB.log).toHaveBeenNthCalledWith(1, 'warn', 'message2', expect.any(Object)); - expect(wrappedB.log).toHaveBeenNthCalledWith(2, 'error', 'message3', expect.any(Object)); - }); - - it('does not store more messages than the buffer limit.', (): void => { - lazyLoggerFactory = new LazyLoggerFactory({ bufferSize: 100 }); - const loggerA = lazyLoggerFactory.createLogger('LoggerA'); - const loggerB = lazyLoggerFactory.createLogger('LoggerB'); - - for (let i = 0; i < 50; i++) { - loggerA.info('info'); - } - for (let i = 0; i < 50; i++) { - loggerB.info('info'); - } - - lazyLoggerFactory.loggerFactory = dummyLoggerFactory; - - expect(dummyLoggerFactory.createLogger).toHaveBeenCalledTimes(3); - const wrappedA = dummyLoggerFactory.createLogger.mock.results[0].value as jest.Mocked; - const wrappedB = dummyLoggerFactory.createLogger.mock.results[1].value as jest.Mocked; - const warningLogger = dummyLoggerFactory.createLogger.mock.results[2].value as jest.Mocked; - - expect(wrappedA.log).toHaveBeenCalledTimes(50); - expect(wrappedB.log).toHaveBeenCalledTimes(49); - expect(warningLogger.log).toHaveBeenCalledTimes(1); - expect(warningLogger.log).toHaveBeenCalledWith( - 'warn', - 'Memory-buffered logging limit of 100 reached', - expect.any(Object), - ); - }); -}); diff --git a/test/unit/logging/LogUtil.test.ts b/test/unit/logging/LogUtil.test.ts deleted file mode 100644 index bb9418bec..000000000 --- a/test/unit/logging/LogUtil.test.ts +++ /dev/null @@ -1,40 +0,0 @@ -import { getLoggerFor, resetInternalLoggerFactory, setGlobalLoggerFactory } from '../../../src/logging/LogUtil'; - -let currentFactory: any; - -class Dummy { - private readonly label = 'dummy'; -} - -describe('LogUtil', (): void => { - beforeAll((): void => { - resetInternalLoggerFactory(); - resetInternalLoggerFactory({ - get loggerFactory(): any { - return currentFactory; - }, - set loggerFactory(value: any) { - currentFactory = value; - }, - createLogger: jest.fn((label: string): any => ({ label })), - } as any); - }); - - it('allows creating a lazy logger for a string label.', async(): Promise => { - expect(getLoggerFor('MyLabel')).toEqual({ label: 'MyLabel' }); - }); - - it('allows creating a lazy logger for a class instance.', async(): Promise => { - expect(getLoggerFor(new Dummy())).toEqual({ label: 'Dummy' }); - }); - - it('reuses loggers for instances of the same class.', async(): Promise => { - expect(getLoggerFor(new Dummy())).toBe(getLoggerFor(new Dummy())); - }); - - it('allows setting the global logger factory.', async(): Promise => { - const factory = {} as any; - setGlobalLoggerFactory(factory); - expect(currentFactory).toBe(factory); - }); -}); diff --git a/test/unit/logging/Logger.test.ts b/test/unit/logging/Logger.test.ts deleted file mode 100644 index 212f6717d..000000000 --- a/test/unit/logging/Logger.test.ts +++ /dev/null @@ -1,109 +0,0 @@ -import { BaseLogger, WrappingLogger } from '../../../src/logging/Logger'; -import type { LogMetadata, SimpleLogger } from '../../../src/logging/Logger'; - -class DummyLogger extends BaseLogger { - public log(): this { - return this; - } -} - -describe('Logger', (): void => { - describe('a BaseLogger', (): void => { - let logger: BaseLogger; - const metadata: LogMetadata = { - isPrimary: true, - pid: process.pid, - }; - - beforeEach(async(): Promise => { - logger = new DummyLogger(); - jest.spyOn(logger, 'log').mockImplementation(); - }); - - it('delegates error to log.', async(): Promise => { - logger.error('my message'); - expect(logger.log).toHaveBeenCalledTimes(1); - expect(logger.log).toHaveBeenCalledWith('error', 'my message', metadata); - }); - - it('warn delegates to log.', async(): Promise => { - logger.warn('my message'); - expect(logger.log).toHaveBeenCalledTimes(1); - expect(logger.log).toHaveBeenCalledWith('warn', 'my message', metadata); - }); - - it('info delegates to log.', async(): Promise => { - logger.info('my message'); - expect(logger.log).toHaveBeenCalledTimes(1); - expect(logger.log).toHaveBeenCalledWith('info', 'my message', metadata); - }); - - it('verbose delegates to log.', async(): Promise => { - logger.verbose('my message'); - expect(logger.log).toHaveBeenCalledTimes(1); - expect(logger.log).toHaveBeenCalledWith('verbose', 'my message', metadata); - }); - - it('debug delegates to log.', async(): Promise => { - logger.debug('my message'); - expect(logger.log).toHaveBeenCalledTimes(1); - expect(logger.log).toHaveBeenCalledWith('debug', 'my message', metadata); - }); - - it('silly delegates to log.', async(): Promise => { - logger.silly('my message'); - expect(logger.log).toHaveBeenCalledTimes(1); - expect(logger.log).toHaveBeenCalledWith('silly', 'my message', metadata); - }); - }); - - describe('a WrappingLogger', (): void => { - let logger: SimpleLogger; - let wrapper: WrappingLogger; - const metadata: LogMetadata = { - isPrimary: true, - pid: process.pid, - }; - - beforeEach(async(): Promise => { - logger = { log: jest.fn() }; - wrapper = new WrappingLogger(logger); - }); - - it('error delegates to the internal logger.', async(): Promise => { - wrapper.error('my message'); - expect(logger.log).toHaveBeenCalledTimes(1); - expect(logger.log).toHaveBeenCalledWith('error', 'my message', metadata); - }); - - it('warn delegates to the internal logger.', async(): Promise => { - wrapper.warn('my message'); - expect(logger.log).toHaveBeenCalledTimes(1); - expect(logger.log).toHaveBeenCalledWith('warn', 'my message', metadata); - }); - - it('info delegates to the internal logger.', async(): Promise => { - wrapper.info('my message'); - expect(logger.log).toHaveBeenCalledTimes(1); - expect(logger.log).toHaveBeenCalledWith('info', 'my message', metadata); - }); - - it('verbose delegates to the internal logger.', async(): Promise => { - wrapper.verbose('my message'); - expect(logger.log).toHaveBeenCalledTimes(1); - expect(logger.log).toHaveBeenCalledWith('verbose', 'my message', metadata); - }); - - it('debug delegates to the internal logger.', async(): Promise => { - wrapper.debug('my message'); - expect(logger.log).toHaveBeenCalledTimes(1); - expect(logger.log).toHaveBeenCalledWith('debug', 'my message', metadata); - }); - - it('silly delegates to the internal logger.', async(): Promise => { - wrapper.silly('my message'); - expect(logger.log).toHaveBeenCalledTimes(1); - expect(logger.log).toHaveBeenCalledWith('silly', 'my message', metadata); - }); - }); -}); diff --git a/test/unit/logging/VoidLogger.test.ts b/test/unit/logging/VoidLogger.test.ts deleted file mode 100644 index aaf7a1b64..000000000 --- a/test/unit/logging/VoidLogger.test.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { VoidLogger } from '../../../src/logging/VoidLogger'; - -describe('VoidLogger', (): void => { - let logger: VoidLogger; - beforeEach(async(): Promise => { - logger = new VoidLogger(); - }); - - it('does nothing when log is invoked.', async(): Promise => { - expect(logger.log()).toBe(logger); - }); -}); diff --git a/test/unit/logging/VoidLoggerFactory.test.ts b/test/unit/logging/VoidLoggerFactory.test.ts deleted file mode 100644 index f46a57780..000000000 --- a/test/unit/logging/VoidLoggerFactory.test.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { VoidLogger } from '../../../src/logging/VoidLogger'; -import { VoidLoggerFactory } from '../../../src/logging/VoidLoggerFactory'; - -describe('VoidLoggerFactory', (): void => { - let factory: VoidLoggerFactory; - beforeEach(async(): Promise => { - factory = new VoidLoggerFactory(); - }); - - it('creates VoidLoggers.', async(): Promise => { - const logger = factory.createLogger('MyLabel'); - expect(logger).toBeInstanceOf(VoidLogger); - }); -}); diff --git a/test/unit/logging/WinstonLogger.test.ts b/test/unit/logging/WinstonLogger.test.ts deleted file mode 100644 index f4d61e879..000000000 --- a/test/unit/logging/WinstonLogger.test.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { WinstonLogger } from '../../../src/logging/WinstonLogger'; - -describe('WinstonLogger', (): void => { - let innerLogger: any; - let logger: WinstonLogger; - beforeEach(async(): Promise => { - innerLogger = { - log: jest.fn(), - }; - logger = new WinstonLogger(innerLogger); - }); - - it('delegates log invocations to the inner logger.', async(): Promise => { - expect(logger.log('debug', 'my message', { abc: true })).toBe(logger); - expect(innerLogger.log).toHaveBeenCalledTimes(1); - expect(innerLogger.log).toHaveBeenCalledWith('debug', 'my message', { abc: true }); - }); -}); diff --git a/test/unit/logging/WinstonLoggerFactory.test.ts b/test/unit/logging/WinstonLoggerFactory.test.ts deleted file mode 100644 index d39fc22f2..000000000 --- a/test/unit/logging/WinstonLoggerFactory.test.ts +++ /dev/null @@ -1,77 +0,0 @@ -import { PassThrough } from 'node:stream'; -import type { Logger } from 'winston'; -import type * as Transport from 'winston-transport'; -import { WinstonLogger } from '../../../src/logging/WinstonLogger'; -import { WinstonLoggerFactory } from '../../../src/logging/WinstonLoggerFactory'; - -const now = new Date(); -jest.useFakeTimers(); -jest.setSystemTime(now); - -describe('WinstonLoggerFactory', (): void => { - let factory: WinstonLoggerFactory; - let transport: jest.Mocked; - - beforeEach(async(): Promise => { - factory = new WinstonLoggerFactory('debug'); - - // Create a dummy log transport - transport = new PassThrough({ objectMode: true }) as any; - jest.spyOn(transport, 'write').mockImplementation(); - // eslint-disable-next-line jest/prefer-spy-on - transport.log = jest.fn(); - }); - - it('creates WinstonLoggers.', async(): Promise => { - const logger = factory.createLogger('MyLabel'); - expect(logger).toBeInstanceOf(WinstonLogger); - const innerLogger: Logger = (logger as any).logger; - expect(innerLogger.level).toBe('debug'); - expect(innerLogger.format).toBeTruthy(); - expect(innerLogger.transports).toHaveLength(1); - }); - - it('allows WinstonLoggers to be invoked.', async(): Promise => { - (factory as any).createTransports = (): any => [ transport ]; - - // Create logger, and log - const logger = factory.createLogger('MyLabel'); - logger.log('debug', 'my message'); - - expect(transport.write).toHaveBeenCalledTimes(1); - // Need to check level like this as it has color tags - const { level } = transport.write.mock.calls[0][0]; - expect(transport.write).toHaveBeenCalledWith({ - label: 'MyLabel', - level, - message: 'my message', - timestamp: now.toISOString(), - metadata: {}, - [Symbol.for('level')]: 'debug', - [Symbol.for('splat')]: [ undefined ], - [Symbol.for('message')]: `${now.toISOString()} [MyLabel] {W-???} ${level}: my message`, - }); - }); - - it('allows extra metadata when logging to indicate the thread.', async(): Promise => { - (factory as any).createTransports = (): any => [ transport ]; - - // Create logger, and log - const logger = factory.createLogger('MyLabel'); - logger.log('debug', 'my message', { isPrimary: true, pid: 0 }); - - expect(transport.write).toHaveBeenCalledTimes(1); - // Need to check level like this as it has color tags - const { level } = transport.write.mock.calls[0][0]; - expect(transport.write).toHaveBeenCalledWith(expect.objectContaining({ - label: 'MyLabel', - level, - message: 'my message', - timestamp: now.toISOString(), - metadata: { isPrimary: true, pid: 0 }, - [Symbol.for('level')]: 'debug', - [Symbol.for('splat')]: [{ isPrimary: true, pid: 0 }], - [Symbol.for('message')]: `${now.toISOString()} [MyLabel] {Primary} ${level}: my message`, - })); - }); -}); diff --git a/test/unit/server/HandlerServerConfigurator.test.ts b/test/unit/server/HandlerServerConfigurator.test.ts index 0c2ee20c1..1a1ee93bf 100644 --- a/test/unit/server/HandlerServerConfigurator.test.ts +++ b/test/unit/server/HandlerServerConfigurator.test.ts @@ -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 }; diff --git a/test/unit/server/WebSocketServerConfigurator.test.ts b/test/unit/server/WebSocketServerConfigurator.test.ts index 106e9e006..0b7fe6be9 100644 --- a/test/unit/server/WebSocketServerConfigurator.test.ts +++ b/test/unit/server/WebSocketServerConfigurator.test.ts @@ -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 }; diff --git a/test/unit/server/notifications/KeyValueChannelStorage.test.ts b/test/unit/server/notifications/KeyValueChannelStorage.test.ts index 61468f7c5..0ed649d33 100644 --- a/test/unit/server/notifications/KeyValueChannelStorage.test.ts +++ b/test/unit/server/notifications/KeyValueChannelStorage.test.ts @@ -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 }; }); diff --git a/test/unit/server/notifications/ListeningActivityHandler.test.ts b/test/unit/server/notifications/ListeningActivityHandler.test.ts index a5226810a..53fc3ba54 100644 --- a/test/unit/server/notifications/ListeningActivityHandler.test.ts +++ b/test/unit/server/notifications/ListeningActivityHandler.test.ts @@ -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 }; }); diff --git a/test/unit/server/notifications/NotificationSubscriber.test.ts b/test/unit/server/notifications/NotificationSubscriber.test.ts index 864b8db88..2270ce04d 100644 --- a/test/unit/server/notifications/NotificationSubscriber.test.ts +++ b/test/unit/server/notifications/NotificationSubscriber.test.ts @@ -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 }; diff --git a/test/unit/server/notifications/StreamingHttpChannel2023/StreamingHttpListeningActivityHandler.test.ts b/test/unit/server/notifications/StreamingHttpChannel2023/StreamingHttpListeningActivityHandler.test.ts index 7554b3917..49255ac67 100644 --- a/test/unit/server/notifications/StreamingHttpChannel2023/StreamingHttpListeningActivityHandler.test.ts +++ b/test/unit/server/notifications/StreamingHttpChannel2023/StreamingHttpListeningActivityHandler.test.ts @@ -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 }; }); diff --git a/test/unit/server/notifications/StreamingHttpChannel2023/StreamingHttpRequestHandler.test.ts b/test/unit/server/notifications/StreamingHttpChannel2023/StreamingHttpRequestHandler.test.ts index 1c4e19862..01c496aaf 100644 --- a/test/unit/server/notifications/StreamingHttpChannel2023/StreamingHttpRequestHandler.test.ts +++ b/test/unit/server/notifications/StreamingHttpChannel2023/StreamingHttpRequestHandler.test.ts @@ -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 }; }); diff --git a/test/unit/server/notifications/WebHookChannel2023/WebhookChannel2023Type.test.ts b/test/unit/server/notifications/WebHookChannel2023/WebhookChannel2023Type.test.ts index 825d46504..966ce94ea 100644 --- a/test/unit/server/notifications/WebHookChannel2023/WebhookChannel2023Type.test.ts +++ b/test/unit/server/notifications/WebHookChannel2023/WebhookChannel2023Type.test.ts @@ -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 }; diff --git a/test/unit/server/notifications/WebHookChannel2023/WebhookEmitter.test.ts b/test/unit/server/notifications/WebHookChannel2023/WebhookEmitter.test.ts index 8ead03aec..fd0abb3c9 100644 --- a/test/unit/server/notifications/WebHookChannel2023/WebhookEmitter.test.ts +++ b/test/unit/server/notifications/WebHookChannel2023/WebhookEmitter.test.ts @@ -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 }; diff --git a/test/unit/util/GuardedStream.test.ts b/test/unit/util/GuardedStream.test.ts index b1226247e..9c34c6921 100644 --- a/test/unit/util/GuardedStream.test.ts +++ b/test/unit/util/GuardedStream.test.ts @@ -1,10 +1,10 @@ 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 { guardStream, isGuarded } from '../../../src/util/GuardedStream'; import { readableToString } from '../../../src/util/StreamUtil'; -jest.mock('../../../src/logging/LogUtil', (): any => { +jest.mock('global-logger-factory', (): any => { const logger: Logger = { error: jest.fn() } as any; return { getLoggerFor: (): Logger => logger }; }); diff --git a/test/unit/util/StreamUtil.test.ts b/test/unit/util/StreamUtil.test.ts index cd85e8e04..869cf840c 100644 --- a/test/unit/util/StreamUtil.test.ts +++ b/test/unit/util/StreamUtil.test.ts @@ -1,8 +1,8 @@ import { PassThrough, Readable } from 'node:stream'; import arrayifyStream from 'arrayify-stream'; import { BlankNode, Literal, NamedNode, Quad, Store } from 'n3'; -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 { isHttpRequest } from '../../../src/server/HttpRequest'; import { getSingleItem, @@ -15,7 +15,7 @@ import { } from '../../../src/util/StreamUtil'; import { flushPromises } from '../../util/Util'; -jest.mock('../../../src/logging/LogUtil', (): any => { +jest.mock('global-logger-factory', (): any => { const logger: Logger = { warn: jest.fn(), log: jest.fn() } as any; return { getLoggerFor: (): Logger => logger }; }); diff --git a/test/unit/util/TimerUtil.test.ts b/test/unit/util/TimerUtil.test.ts index 014344037..aa013e399 100644 --- a/test/unit/util/TimerUtil.test.ts +++ b/test/unit/util/TimerUtil.test.ts @@ -1,4 +1,4 @@ -import type { Logger } from '../../../src/logging/Logger'; +import type { Logger } from 'global-logger-factory'; import { setSafeInterval } from '../../../src/util/TimerUtil'; import { flushPromises } from '../../util/Util'; diff --git a/test/util/SetupTests.ts b/test/util/SetupTests.ts index ebebad1da..d21f65373 100644 --- a/test/util/SetupTests.ts +++ b/test/util/SetupTests.ts @@ -1,5 +1,4 @@ -import { setGlobalLoggerFactory } from '../../src/logging/LogUtil'; -import { WinstonLoggerFactory } from '../../src/logging/WinstonLoggerFactory'; +import { setGlobalLoggerFactory, WinstonLoggerFactory } from 'global-logger-factory'; import { getTestFolder, removeFolder } from '../integration/Config'; // Jest global setup requires a single function to be exported