mirror of
https://github.com/CommunitySolidServer/CommunitySolidServer.git
synced 2024-10-03 14:55:10 +00:00
feat: Replace logging with external library
This commit is contained in:
parent
3902eccbde
commit
dce39f67e8
@ -42,7 +42,6 @@
|
||||
"VariableBindings",
|
||||
"UnionHandler",
|
||||
"VirtualObject",
|
||||
"WinstonLogger",
|
||||
"WrappedSetMultiMap",
|
||||
"YargsOptions"
|
||||
]
|
||||
|
@ -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.",
|
||||
|
@ -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",
|
||||
|
@ -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",
|
||||
|
@ -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';
|
||||
|
@ -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';
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { getLoggerFor } from '../logging/LogUtil';
|
||||
import { getLoggerFor } from 'global-logger-factory';
|
||||
import type { Credentials } from './Credentials';
|
||||
import { CredentialsExtractor } from './CredentialsExtractor';
|
||||
|
||||
|
@ -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';
|
||||
|
@ -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';
|
||||
|
@ -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';
|
||||
|
@ -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';
|
||||
|
@ -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';
|
||||
|
@ -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';
|
||||
|
@ -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';
|
||||
|
@ -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';
|
||||
|
@ -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';
|
||||
|
@ -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';
|
||||
|
@ -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';
|
||||
|
@ -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';
|
||||
|
@ -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';
|
||||
|
@ -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';
|
||||
|
@ -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';
|
||||
|
@ -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';
|
||||
|
@ -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';
|
||||
|
@ -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';
|
||||
|
@ -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';
|
||||
|
@ -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';
|
||||
|
@ -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';
|
||||
|
@ -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';
|
||||
|
@ -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';
|
||||
|
@ -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';
|
||||
|
@ -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';
|
||||
|
@ -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';
|
||||
|
@ -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';
|
||||
|
@ -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';
|
||||
|
@ -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';
|
||||
|
@ -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';
|
||||
|
@ -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';
|
||||
|
@ -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';
|
||||
|
@ -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';
|
||||
|
@ -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';
|
||||
|
@ -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';
|
||||
|
@ -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';
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { getLoggerFor } from '../../../../logging/LogUtil';
|
||||
import { getLoggerFor } from 'global-logger-factory';
|
||||
import type {
|
||||
CreateTypeObject,
|
||||
IndexedQuery,
|
||||
|
@ -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';
|
||||
|
@ -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';
|
||||
|
@ -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';
|
||||
|
@ -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';
|
||||
|
@ -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';
|
||||
|
@ -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';
|
||||
|
@ -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';
|
||||
|
@ -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';
|
||||
|
@ -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';
|
||||
|
@ -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';
|
||||
|
@ -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';
|
||||
|
@ -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';
|
||||
|
@ -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';
|
||||
|
||||
|
@ -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';
|
||||
|
@ -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';
|
||||
|
@ -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';
|
||||
|
@ -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';
|
||||
|
@ -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';
|
||||
|
@ -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';
|
||||
|
@ -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';
|
||||
|
@ -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';
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { getLoggerFor } from '../../logging/LogUtil';
|
||||
import { getLoggerFor } from 'global-logger-factory';
|
||||
import { OwnershipValidator } from './OwnershipValidator';
|
||||
|
||||
/**
|
||||
|
@ -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';
|
||||
|
@ -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';
|
||||
|
@ -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';
|
||||
|
||||
|
11
src/index.ts
11
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';
|
||||
|
@ -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';
|
||||
|
@ -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';
|
||||
|
||||
|
@ -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';
|
||||
|
@ -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';
|
||||
|
@ -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';
|
||||
|
||||
/**
|
||||
|
@ -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';
|
||||
|
||||
|
@ -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';
|
||||
|
@ -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';
|
||||
|
||||
/**
|
||||
|
@ -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';
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
@ -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];
|
@ -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<Constructor, Logger>();
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
@ -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() ];
|
||||
}
|
||||
}
|
@ -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';
|
||||
|
@ -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';
|
||||
|
@ -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,
|
||||
|
@ -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';
|
||||
|
@ -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';
|
||||
|
@ -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';
|
||||
|
||||
|
@ -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';
|
||||
|
@ -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';
|
||||
|
@ -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';
|
||||
|
@ -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';
|
||||
|
@ -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';
|
||||
|
@ -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';
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user