Merge pull request #4405 from GoWind/supress-log-single-location

Supress log single location. Refs #3602
This commit is contained in:
Patrik Oldsberg
2021-02-08 17:53:29 +01:00
committed by GitHub
2 changed files with 15 additions and 6 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/plugin-catalog-backend': patch
---
use child logger, if provided, to log single location refresh
@@ -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)}`,