diff --git a/packages/core/saved-objects/core-saved-objects-import-export-server-internal/src/import/saved_objects_importer.ts b/packages/core/saved-objects/core-saved-objects-import-export-server-internal/src/import/saved_objects_importer.ts index 5b94b84cefff..f990eb13c435 100644 --- a/packages/core/saved-objects/core-saved-objects-import-export-server-internal/src/import/saved_objects_importer.ts +++ b/packages/core/saved-objects/core-saved-objects-import-export-server-internal/src/import/saved_objects_importer.ts @@ -9,6 +9,7 @@ import type { SavedObjectsImportResponse } from '@kbn/core-saved-objects-common'; import type { SavedObjectsClientContract } from '@kbn/core-saved-objects-api-server'; +import type { Logger } from '@kbn/logging'; import type { ISavedObjectTypeRegistry, ISavedObjectsImporter, @@ -27,15 +28,18 @@ export class SavedObjectsImporter implements ISavedObjectsImporter { readonly #typeRegistry: ISavedObjectTypeRegistry; readonly #importSizeLimit: number; readonly #importHooks: Record; + readonly #log: Logger; constructor({ savedObjectsClient, typeRegistry, importSizeLimit, + logger, }: { savedObjectsClient: SavedObjectsClientContract; typeRegistry: ISavedObjectTypeRegistry; importSizeLimit: number; + logger: Logger; }) { this.#savedObjectsClient = savedObjectsClient; this.#typeRegistry = typeRegistry; @@ -46,6 +50,7 @@ export class SavedObjectsImporter implements ISavedObjectsImporter { } return hooks; }, {} as Record); + this.#log = logger; } public import({ @@ -57,6 +62,7 @@ export class SavedObjectsImporter implements ISavedObjectsImporter { compatibilityMode, managed, }: SavedObjectsImportOptions): Promise { + this.#log.debug('Starting the import process'); return importSavedObjectsFromStream({ readStream, createNewCopies, @@ -80,6 +86,7 @@ export class SavedObjectsImporter implements ISavedObjectsImporter { retries, managed, }: SavedObjectsResolveImportErrorsOptions): Promise { + this.#log.debug('Resolving import errors'); return resolveSavedObjectsImportErrors({ readStream, createNewCopies, diff --git a/packages/core/saved-objects/core-saved-objects-server-internal/src/saved_objects_service.ts b/packages/core/saved-objects/core-saved-objects-server-internal/src/saved_objects_service.ts index c831d58f3a56..522a8e1943a2 100644 --- a/packages/core/saved-objects/core-saved-objects-server-internal/src/saved_objects_service.ts +++ b/packages/core/saved-objects/core-saved-objects-server-internal/src/saved_objects_service.ts @@ -376,6 +376,7 @@ export class SavedObjectsService savedObjectsClient, typeRegistry: this.typeRegistry, importSizeLimit: options?.importSizeLimit ?? this.config!.maxImportExportSize, + logger: this.logger.get('importer'), }), getTypeRegistry: () => this.typeRegistry, getDefaultIndex: () => MAIN_SAVED_OBJECT_INDEX, diff --git a/src/core/server/integration_tests/saved_objects/routes/import.test.ts b/src/core/server/integration_tests/saved_objects/routes/import.test.ts index a81196dcbb91..917f7f1642e8 100644 --- a/src/core/server/integration_tests/saved_objects/routes/import.test.ts +++ b/src/core/server/integration_tests/saved_objects/routes/import.test.ts @@ -13,6 +13,7 @@ import supertest from 'supertest'; import { SavedObjectsErrorHelpers } from '@kbn/core-saved-objects-server'; import { savedObjectsClientMock } from '@kbn/core-saved-objects-api-server-mocks'; import type { ICoreUsageStatsClient } from '@kbn/core-usage-data-base-server-internal'; +import type { Logger, LogLevelId } from '@kbn/logging'; import { coreUsageStatsClientMock, coreUsageDataServiceMock, @@ -56,6 +57,17 @@ describe(`POST ${URL}`, () => { references: [], managed: false, }; + const mockLogger: jest.Mocked = { + debug: jest.fn(), + info: jest.fn(), + error: jest.fn(), + warn: jest.fn(), + trace: jest.fn(), + fatal: jest.fn(), + log: jest.fn(), + isLevelEnabled: jest.fn((level: LogLevelId) => true), + get: jest.fn(() => mockLogger), + }; beforeEach(async () => { ({ server, httpSetup, handlerContext } = await setupServer()); @@ -76,6 +88,7 @@ describe(`POST ${URL}`, () => { savedObjectsClient, typeRegistry: handlerContext.savedObjects.typeRegistry, importSizeLimit: 10000, + logger: mockLogger, }); handlerContext.savedObjects.getImporter = jest .fn() diff --git a/src/core/server/integration_tests/saved_objects/routes/resolve_import_errors.test.ts b/src/core/server/integration_tests/saved_objects/routes/resolve_import_errors.test.ts index e31124333cbd..01fcf0683d1f 100644 --- a/src/core/server/integration_tests/saved_objects/routes/resolve_import_errors.test.ts +++ b/src/core/server/integration_tests/saved_objects/routes/resolve_import_errors.test.ts @@ -12,6 +12,7 @@ jest.mock('uuid'); import supertest from 'supertest'; import { savedObjectsClientMock } from '@kbn/core-saved-objects-api-server-mocks'; import type { ICoreUsageStatsClient } from '@kbn/core-usage-data-base-server-internal'; +import type { Logger, LogLevelId } from '@kbn/logging'; import { coreUsageStatsClientMock, coreUsageDataServiceMock, @@ -61,6 +62,17 @@ describe(`POST ${URL}`, () => { references: [], managed: false, }; + const mockLogger: jest.Mocked = { + debug: jest.fn(), + info: jest.fn(), + error: jest.fn(), + warn: jest.fn(), + trace: jest.fn(), + fatal: jest.fn(), + log: jest.fn(), + isLevelEnabled: jest.fn((level: LogLevelId) => true), + get: jest.fn(() => mockLogger), + }; beforeEach(async () => { ({ server, httpSetup, handlerContext } = await setupServer()); @@ -82,6 +94,7 @@ describe(`POST ${URL}`, () => { savedObjectsClient, typeRegistry: handlerContext.savedObjects.typeRegistry, importSizeLimit: 10000, + logger: mockLogger, }); handlerContext.savedObjects.getImporter = jest