feat: Add logging

* feat: Add logging

* refactor: Configure the logger for the tests once globally

* feat: Add logging

* fix: Fix ESLint errors due to merge conflicts

* Review log and error messages.

* refactor: Cleanup a bit

* refactor: Change to logger info calls

Co-authored-by: Ruben Verborgh <ruben@verborgh.org>
This commit is contained in:
smessie
2020-10-26 10:31:01 +01:00
committed by GitHub
parent 1ef75126ee
commit 99464d9a95
38 changed files with 232 additions and 107 deletions

View File

@@ -1,6 +1,7 @@
import type { Representation } from '../ldp/representation/Representation';
import type { RepresentationPreferences } from '../ldp/representation/RepresentationPreferences';
import type { ResourceIdentifier } from '../ldp/representation/ResourceIdentifier';
import { getLoggerFor } from '../logging/LogUtil';
import { matchingMediaType } from '../util/Util';
import type { Conditions } from './Conditions';
import type { RepresentationConverter } from './conversion/RepresentationConverter';
@@ -17,6 +18,8 @@ import type { ResourceStore } from './ResourceStore';
* if there is a low weight for that type conversions might still be preferred.
*/
export class RepresentationConvertingStore<T extends ResourceStore = ResourceStore> extends PassthroughStore<T> {
protected readonly logger = getLoggerFor(this);
private readonly converter: RepresentationConverter;
public constructor(source: T, converter: RepresentationConverter) {
@@ -30,6 +33,7 @@ export class RepresentationConvertingStore<T extends ResourceStore = ResourceSto
if (this.matchesPreferences(representation, preferences)) {
return representation;
}
this.logger.info(`Convert ${identifier.path} from ${representation.metadata.contentType} to ${preferences.type}`);
return this.converter.handleSafe({ identifier, representation, preferences });
}