diff --git a/.changeset/late-ants-impress.md b/.changeset/late-ants-impress.md index c694cea7c4..44b2cbefb3 100644 --- a/.changeset/late-ants-impress.md +++ b/.changeset/late-ants-impress.md @@ -8,4 +8,4 @@ '@backstage/plugin-events-node': patch --- -Replace the usage of `getVoidLogger` with `mockServices.logger.mock` in order to remove the dependency with the soon-to-deprecate `backend-common` package. +Replace the usage of `getVoidLogger` with `mockServices.logger.mock` in order to remove the dependency with the soon-to-be-deprecated `backend-common` package. diff --git a/.changeset/old-trees-check.md b/.changeset/old-trees-check.md index 4c259bf4d7..b4d745ffb5 100644 --- a/.changeset/old-trees-check.md +++ b/.changeset/old-trees-check.md @@ -2,4 +2,4 @@ '@backstage/backend-tasks': patch --- -Deprecate the legacy `TaskScheduler.fromConfig` method and stop using the `getVoidlogger` in tests files to reduce the dependecy on the soon-to-deprecate `backstage-common` package. +Deprecate the legacy `TaskScheduler.fromConfig` method and stop using the `getVoidlogger` in tests files to reduce the dependency on the soon-to-deprecate `backstage-common` package. diff --git a/.changeset/olive-mangos-tickle.md b/.changeset/olive-mangos-tickle.md index d28d250ca3..6033ec3ed6 100644 --- a/.changeset/olive-mangos-tickle.md +++ b/.changeset/olive-mangos-tickle.md @@ -2,4 +2,4 @@ '@backstage/backend-app-api': patch --- -Export a new `VoidLogger` implementation and stop using `getVoidLogger` in tests to reduce the dependecy on the soon-to-deprecate `backstage-common` package. +Stop using `getVoidLogger` in tests to reduce the dependency on the soon-to-deprecate `backstage-common` package. diff --git a/packages/backend-app-api/api-report.md b/packages/backend-app-api/api-report.md index 1d681c308b..5720c1c60f 100644 --- a/packages/backend-app-api/api-report.md +++ b/packages/backend-app-api/api-report.md @@ -347,22 +347,6 @@ export const userInfoServiceFactory: () => ServiceFactory< 'plugin' >; -// @public -export class VoidLogger implements RootLoggerService { - // (undocumented) - child(_meta: JsonObject): LoggerService; - // (undocumented) - static create(): VoidLogger; - // (undocumented) - debug(_message: string, _meta?: JsonObject): void; - // (undocumented) - error(_message: string, _meta?: JsonObject): void; - // (undocumented) - info(_message: string, _meta?: JsonObject): void; - // (undocumented) - warn(_message: string, _meta?: JsonObject): void; -} - // @public export class WinstonLogger implements RootLoggerService { // (undocumented) diff --git a/packages/backend-app-api/src/logging/VoidLogger.ts b/packages/backend-app-api/src/logging/VoidLogger.ts deleted file mode 100644 index 0f5acba07f..0000000000 --- a/packages/backend-app-api/src/logging/VoidLogger.ts +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright 2023 The Backstage Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { - LoggerService, - RootLoggerService, -} from '@backstage/backend-plugin-api'; -import { JsonObject } from '@backstage/types'; - -/** - * An empty {@link @backstage/backend-plugin-api#LoggerService} implementation. - * - * @public - */ -export class VoidLogger implements RootLoggerService { - static create(): VoidLogger { - return new VoidLogger(); - } - - error(_message: string, _meta?: JsonObject): void {} - - warn(_message: string, _meta?: JsonObject): void {} - - info(_message: string, _meta?: JsonObject): void {} - - debug(_message: string, _meta?: JsonObject): void {} - - child(_meta: JsonObject): LoggerService { - return new VoidLogger(); - } -} diff --git a/packages/backend-app-api/src/logging/index.ts b/packages/backend-app-api/src/logging/index.ts index a7162553e3..14fe33f898 100644 --- a/packages/backend-app-api/src/logging/index.ts +++ b/packages/backend-app-api/src/logging/index.ts @@ -14,6 +14,5 @@ * limitations under the License. */ -export { VoidLogger } from './VoidLogger'; export { WinstonLogger } from './WinstonLogger'; export type { WinstonLoggerOptions } from './WinstonLogger'; diff --git a/plugins/search-backend-module-pg/src/PgSearchEngine/PgSearchEngineIndexer.ts b/plugins/search-backend-module-pg/src/PgSearchEngine/PgSearchEngineIndexer.ts index 93b699fc74..ab5ae8be54 100644 --- a/plugins/search-backend-module-pg/src/PgSearchEngine/PgSearchEngineIndexer.ts +++ b/plugins/search-backend-module-pg/src/PgSearchEngine/PgSearchEngineIndexer.ts @@ -14,13 +14,11 @@ * limitations under the License. */ -import { loggerToWinstonLogger } from '@backstage/backend-common'; import { BatchSearchEngineIndexer } from '@backstage/plugin-search-backend-node'; import { IndexableDocument } from '@backstage/plugin-search-common'; import { Knex } from 'knex'; import { Logger } from 'winston'; import { DatabaseStore } from '../database'; -import { VoidLogger } from '@backstage/backend-app-api'; /** @public */ export type PgSearchEngineIndexerOptions = { @@ -32,7 +30,7 @@ export type PgSearchEngineIndexerOptions = { /** @public */ export class PgSearchEngineIndexer extends BatchSearchEngineIndexer { - private logger: Logger; + private logger?: Logger; private store: DatabaseStore; private type: string; private tx: Knex.Transaction | undefined; @@ -42,7 +40,7 @@ export class PgSearchEngineIndexer extends BatchSearchEngineIndexer { super({ batchSize: options.batchSize }); this.store = options.databaseStore; this.type = options.type; - this.logger = options.logger || loggerToWinstonLogger(VoidLogger.create()); + this.logger = options.logger; } async initialize(): Promise { @@ -61,7 +59,7 @@ export class PgSearchEngineIndexer extends BatchSearchEngineIndexer { this.numRecords += documents.length; const refs = [...new Set(documents.map(d => d.authorization?.resourceRef))]; - this.logger.debug( + this.logger?.debug( `Attempting to index the following entities: ${refs.toString()}`, ); @@ -80,7 +78,7 @@ export class PgSearchEngineIndexer extends BatchSearchEngineIndexer { // and do not continue. This ensures that collators that return empty sets // of documents do not cause the index to be deleted. if (this.numRecords === 0) { - this.logger.warn( + this.logger?.warn( `Index for ${this.type} was not replaced: indexer received 0 documents`, ); this.tx!.rollback!();