use child logger to log single location update

This commit is contained in:
Gowind
2021-02-05 15:37:44 +01:00
parent 2cc2d1ad17
commit e84170d644
@@ -130,7 +130,7 @@ export class HigherOrderOperations implements HigherOrderOperation {
`Locations Refresh: Refreshing location ${location.type}:${location.target}`,
);
try {
await this.refreshSingleLocation(location);
await this.refreshSingleLocation(location, logger);
await this.locationsCatalog.logUpdateSuccess(location.id, undefined);
} catch (e) {
logger.warn(
@@ -148,8 +148,12 @@ export class HigherOrderOperations implements HigherOrderOperation {
}
// Performs a full refresh of a single location
private async refreshSingleLocation(location: Location) {
private async refreshSingleLocation(
location: Location,
optionalLogger?: Logger,
) {
let startTimestamp = process.hrtime();
const logger = optionalLogger || this.logger;
const readerOutput = await this.locationReader.read({
type: location.type,
@@ -157,12 +161,12 @@ export class HigherOrderOperations implements HigherOrderOperation {
});
for (const item of readerOutput.errors) {
this.logger.warn(
logger.warn(
`Failed item in location ${item.location.type}:${item.location.target}, ${item.error.stack}`,
);
}
this.logger.info(
logger.info(
`Read ${readerOutput.entities.length} entities from location ${
location.type
}:${location.target} in ${durationText(startTimestamp)}`,
@@ -186,14 +190,14 @@ export class HigherOrderOperations implements HigherOrderOperation {
throw e;
}
this.logger.debug(`Posting update success markers`);
logger.debug(`Posting update success markers`);
await this.locationsCatalog.logUpdateSuccess(
location.id,
readerOutput.entities.map(e => e.entity.metadata.name),
);
this.logger.info(
logger.info(
`Wrote ${readerOutput.entities.length} entities from location ${
location.type
}:${location.target} in ${durationText(startTimestamp)}`,