catalog-github: use logger

Signed-off-by: Vincenzo Scamporlino <vincenzos@spotify.com>
This commit is contained in:
Vincenzo Scamporlino
2024-05-13 12:54:25 +02:00
parent 207f962461
commit 84d443db5f
2 changed files with 7 additions and 3 deletions
@@ -13,13 +13,17 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { LoggerService } from '@backstage/backend-plugin-api';
import {
EntityProvider,
EntityProviderConnection,
} from '@backstage/plugin-catalog-node';
export class GithubOrgEntityCleanerProvider implements EntityProvider {
constructor(private readonly options: { id: string }) {}
logger: LoggerService;
constructor(private readonly options: { id: string; logger: LoggerService }) {
this.logger = options.logger.child({ target: this.getProviderName() });
}
getProviderName() {
return `GithubOrgEntityProvider:${this.options.id}`;
@@ -32,7 +36,7 @@ export class GithubOrgEntityCleanerProvider implements EntityProvider {
entities: [],
})
.catch(error => {
console.error('Failed to clean up entities', error);
this.logger.error('Failed to clean up entities', error);
});
}
}
@@ -106,7 +106,7 @@ export const catalogModuleGithubOrgEntityProvider = createBackendModule({
for (const definition of definitions) {
catalog.addEntityProvider(
new GithubOrgEntityCleanerProvider({ id: definition.id }),
new GithubOrgEntityCleanerProvider({ id: definition.id, logger }),
);
catalog.addEntityProvider(
GithubMultiOrgEntityProvider.fromConfig(config, {