Skip to content

Commit

Permalink
Adapt internal core imports to use @kbn-logging (#132900)
Browse files Browse the repository at this point in the history
* Adapt internal core imports to use `@kbn-logging`

* remove re-export of logger mocks

* re-export @kbn/logging types from the entrypoint now

* fix missing imports

* update generated doc

* update generated doc
  • Loading branch information
pgayvallet authored May 30, 2022
1 parent 7f2c369 commit a044026
Show file tree
Hide file tree
Showing 78 changed files with 91 additions and 115 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ Set of helpers used to create `KibanaResponse` to form HTTP response on an incom

```typescript
kibanaResponseFactory: {
custom: <T extends string | Record<string, any> | Error | Buffer | Stream | {
custom: <T extends string | Record<string, any> | Error | Buffer | {
message: string | Error;
attributes?: ResponseErrorAttributes | undefined;
} | undefined>(options: CustomHttpResponseOptions<T>) => KibanaResponse<T>;
} | Stream | undefined>(options: CustomHttpResponseOptions<T>) => KibanaResponse<T>;
badRequest: (options?: ErrorHttpResponseOptions) => KibanaResponse<string | Error | {
message: string | Error;
attributes?: ResponseErrorAttributes | undefined;
Expand All @@ -34,10 +34,10 @@ kibanaResponseFactory: {
message: string | Error;
attributes?: ResponseErrorAttributes | undefined;
}>;
customError: (options: CustomHttpResponseOptions<ResponseError | Buffer | Stream>) => KibanaResponse<string | Error | Buffer | Stream | {
customError: (options: CustomHttpResponseOptions<ResponseError | Buffer | Stream>) => KibanaResponse<string | Error | Buffer | {
message: string | Error;
attributes?: ResponseErrorAttributes | undefined;
}>;
} | Stream>;
redirected: (options: RedirectResponseOptions) => KibanaResponse<string | Record<string, any> | Buffer | Stream>;
ok: (options?: HttpResponseOptions) => KibanaResponse<string | Record<string, any> | Buffer | Stream>;
accepted: (options?: HttpResponseOptions) => KibanaResponse<string | Record<string, any> | Buffer | Stream>;
Expand Down
2 changes: 1 addition & 1 deletion src/core/server/capabilities/capabilities_service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
* Side Public License, v 1.
*/

import { Logger } from '@kbn/logging';
import { Capabilities, CapabilitiesProvider, CapabilitiesSwitcher } from './types';
import { CoreContext } from '../core_context';
import { Logger } from '../logging';
import { InternalHttpServicePreboot, InternalHttpServiceSetup, KibanaRequest } from '../http';
import { mergeCapabilities } from './merge_capabilities';
import { getCapabilitiesResolver, CapabilitiesResolver } from './resolve_capabilities';
Expand Down
2 changes: 1 addition & 1 deletion src/core/server/core_app/core_app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ import { stringify } from 'querystring';
import { Env } from '@kbn/config';
import { schema } from '@kbn/config-schema';
import { fromRoot } from '@kbn/utils';
import { Logger } from '@kbn/logging';

import { IRouter, IBasePath, IKibanaResponse, KibanaResponseFactory, KibanaRequest } from '../http';
import { HttpResources, HttpResourcesServiceToolkit } from '../http_resources';
import { InternalCorePreboot, InternalCoreSetup } from '../internal_types';
import { CoreContext } from '../core_context';
import { Logger } from '../logging';
import { registerBundleRoutes } from './bundle_routes';
import { UiPlugins } from '../plugins';

Expand Down
2 changes: 1 addition & 1 deletion src/core/server/core_context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
* Side Public License, v 1.
*/

import { LoggerFactory } from '@kbn/logging';
import { IConfigService, Env } from './config';
import { LoggerFactory } from './logging';

/** @internal */
export type CoreId = symbol;
Expand Down
2 changes: 1 addition & 1 deletion src/core/server/deprecations/deprecations_factory.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import type { GetDeprecationsContext } from './types';
import { DeprecationsFactory, DeprecationsFactoryConfig } from './deprecations_factory';
import { loggerMock } from '../logging/logger.mock';
import { loggerMock } from '@kbn/logging-mocks';
import { DeprecationsDetails } from './types';

describe('DeprecationsFactory', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/core/server/deprecations/deprecations_factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
*/

import { i18n } from '@kbn/i18n';
import type { Logger } from '@kbn/logging';
import { DeprecationsRegistry } from './deprecations_registry';
import type { Logger } from '../logging';
import type {
DomainDeprecationDetails,
DeprecationsDetails,
Expand Down
2 changes: 1 addition & 1 deletion src/core/server/deprecations/deprecations_service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import { firstValueFrom } from 'rxjs';

import type { Logger } from '@kbn/logging';
import { DeprecationsFactory } from './deprecations_factory';
import { DomainDeprecationDetails, RegisterDeprecationsConfig } from './types';
import { registerRoutes } from './routes';
Expand All @@ -16,7 +17,6 @@ import { CoreContext } from '../core_context';
import { IConfigService } from '../config';
import { CoreService } from '../../types';
import { InternalHttpServiceSetup } from '../http';
import { Logger } from '../logging';
import { IScopedClusterClient } from '../elasticsearch/client';
import { SavedObjectsClientContract } from '../saved_objects/types';

Expand Down
2 changes: 1 addition & 1 deletion src/core/server/elasticsearch/client/cluster_client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*/

import type { Client } from '@elastic/elasticsearch';
import { Logger } from '../../logging';
import type { Logger } from '@kbn/logging';
import { IAuthHeadersStorage, Headers, isKibanaRequest, isRealRequest } from '../../http';
import { ensureRawRequest, filterHeaders } from '../../http/router';
import { ScopeableRequest } from '../types';
Expand Down
2 changes: 1 addition & 1 deletion src/core/server/elasticsearch/client/configure_client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*/

import { Client, HttpConnection } from '@elastic/elasticsearch';
import { Logger } from '../../logging';
import type { Logger } from '@kbn/logging';
import { parseClientOptions, ElasticsearchClientConfig } from './client_config';
import { instrumentEsQueryAndDeprecationLogger } from './log_query_and_deprecation';
import { createTransport } from './create_transport';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ import { Buffer } from 'buffer';
import { stringify } from 'querystring';
import { errors, DiagnosticResult, RequestBody, Client } from '@elastic/elasticsearch';
import numeral from '@elastic/numeral';
import type { Logger } from '@kbn/logging';
import type { ElasticsearchErrorDetails } from './types';
import { getEcsResponseLog } from './get_ecs_response_log';
import { Logger } from '../../logging';

const convertQueryString = (qs: string | Record<string, any> | undefined): string => {
if (qs === undefined || typeof qs === 'string') {
Expand Down
2 changes: 1 addition & 1 deletion src/core/server/elasticsearch/client/retry_call_cluster.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import { defer, throwError, iif, timer } from 'rxjs';
import { concatMap, retryWhen } from 'rxjs/operators';
import { Logger } from '../../logging';
import type { Logger } from '@kbn/logging';

const retryResponseStatuses = [
503, // ServiceUnavailable
Expand Down
2 changes: 1 addition & 1 deletion src/core/server/elasticsearch/elasticsearch_service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
import { firstValueFrom, Observable, Subject } from 'rxjs';
import { map, shareReplay, takeUntil } from 'rxjs/operators';

import type { Logger } from '@kbn/logging';
import { registerAnalyticsContextProvider } from './register_analytics_context_provider';
import { AnalyticsServiceSetup } from '../analytics';
import { CoreService } from '../../types';
import { CoreContext } from '../core_context';
import { Logger } from '../logging';

import { ClusterClient, ElasticsearchClientConfig } from './client';
import { ElasticsearchConfig, ElasticsearchConfigType } from './elasticsearch_config';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@

import { timer, of, from, Observable } from 'rxjs';
import { map, distinctUntilChanged, catchError, exhaustMap } from 'rxjs/operators';
import type { Logger } from '@kbn/logging';
import {
esVersionCompatibleWithKibana,
esVersionEqualsKibana,
} from './es_kibana_version_compatability';
import { Logger } from '../../logging';
import type { ElasticsearchClient } from '../client';

/** @public */
Expand Down
2 changes: 1 addition & 1 deletion src/core/server/environment/create_data_folder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
*/

import { PathConfigType } from '@kbn/utils';
import type { Logger } from '@kbn/logging';
import { mkdir } from './fs';
import { Logger } from '../logging';

export async function createDataFolder({
pathConfig,
Expand Down
2 changes: 1 addition & 1 deletion src/core/server/environment/environment_service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@

import { firstValueFrom, of } from 'rxjs';
import { PathConfigType, config as pathConfigDef } from '@kbn/utils';
import type { Logger } from '@kbn/logging';
import type { AnalyticsServicePreboot } from '../analytics';
import { CoreContext } from '../core_context';
import { Logger } from '../logging';
import { IConfigService } from '../config';
import { HttpConfigType, config as httpConfigDef } from '../http';
import { PidConfigType, config as pidConfigDef } from './pid_config';
Expand Down
2 changes: 1 addition & 1 deletion src/core/server/environment/resolve_uuid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
import uuid from 'uuid';
import { join } from 'path';
import { PathConfigType } from '@kbn/utils';
import type { Logger } from '@kbn/logging';
import { readFile, writeFile } from './fs';
import { HttpConfigType } from '../http';
import { Logger } from '../logging';
import { uuidRegexp } from '../http/http_config';

const FILE_ENCODING = 'utf8';
Expand Down
2 changes: 1 addition & 1 deletion src/core/server/environment/write_pid_file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import { unlinkSync as unlink } from 'fs';
import once from 'lodash/once';
import { Logger } from '../logging';
import type { Logger } from '@kbn/logging';
import { writeFile, exists } from './fs';
import { PidConfigType } from './pid_config';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ import apm from 'elastic-apm-node';
import { isUndefined, omitBy } from 'lodash';
import type { Subscription } from 'rxjs';

import type { Logger } from '@kbn/logging';
import type { CoreService, KibanaExecutionContext } from '../../types';
import type { CoreContext } from '../core_context';
import type { Logger } from '../logging';
import type { ExecutionContextConfigType } from './execution_context_config';

import {
Expand Down
2 changes: 1 addition & 1 deletion src/core/server/http/http_server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import type { Duration } from 'moment';
import { firstValueFrom, Observable } from 'rxjs';
import { take } from 'rxjs/operators';
import apm from 'elastic-apm-node';
import { Logger, LoggerFactory } from '../logging';
import type { Logger, LoggerFactory } from '@kbn/logging';
import { HttpConfig } from './http_config';
import type { InternalExecutionContextSetup } from '../execution_context';
import { adoptToHapiAuthFormat, AuthenticationHandler } from './lifecycle/auth';
Expand Down
2 changes: 1 addition & 1 deletion src/core/server/http/http_service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ import { Observable, Subscription, combineLatest, firstValueFrom } from 'rxjs';
import { map } from 'rxjs/operators';
import { pick } from '@kbn/std';

import type { Logger } from '@kbn/logging';
import type { RequestHandlerContext } from '..';
import type { InternalExecutionContextSetup } from '../execution_context';
import { CoreService } from '../../types';
import { Logger } from '../logging';
import { ContextSetup, InternalContextPreboot } from '../context';
import { Env } from '../config';
import { CoreContext } from '../core_context';
Expand Down
2 changes: 1 addition & 1 deletion src/core/server/http/https_redirect_server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
import { Request, ResponseToolkit, Server } from '@hapi/hapi';
import { format as formatUrl } from 'url';
import { createServer, getListenerOptions, getServerOptions } from '@kbn/server-http-tools';
import type { Logger } from '@kbn/logging';

import { Logger } from '../logging';
import { HttpConfig } from './http_config';

export class HttpsRedirectServer {
Expand Down
2 changes: 1 addition & 1 deletion src/core/server/http/lifecycle/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*/

import { Lifecycle, Request, ResponseToolkit } from '@hapi/hapi';
import { Logger } from '../../logging';
import type { Logger } from '@kbn/logging';
import {
HapiResponseAdapter,
KibanaRequest,
Expand Down
2 changes: 1 addition & 1 deletion src/core/server/http/lifecycle/on_post_auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*/

import { Lifecycle, Request, ResponseToolkit as HapiResponseToolkit } from '@hapi/hapi';
import { Logger } from '../../logging';
import type { Logger } from '@kbn/logging';
import {
HapiResponseAdapter,
KibanaRequest,
Expand Down
2 changes: 1 addition & 1 deletion src/core/server/http/lifecycle/on_pre_auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*/

import { Lifecycle, Request, ResponseToolkit as HapiResponseToolkit } from '@hapi/hapi';
import { Logger } from '../../logging';
import type { Logger } from '@kbn/logging';
import {
HapiResponseAdapter,
KibanaRequest,
Expand Down
2 changes: 1 addition & 1 deletion src/core/server/http/lifecycle/on_pre_response.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
ResponseToolkit as HapiResponseToolkit,
} from '@hapi/hapi';
import Boom from '@hapi/boom';
import { Logger } from '../../logging';
import type { Logger } from '@kbn/logging';

import { HapiResponseAdapter, KibanaRequest, ResponseHeaders } from '../router';

Expand Down
2 changes: 1 addition & 1 deletion src/core/server/http/lifecycle/on_pre_routing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*/

import { Lifecycle, Request, ResponseToolkit as HapiResponseToolkit } from '@hapi/hapi';
import { Logger } from '../../logging';
import type { Logger } from '@kbn/logging';
import {
HapiResponseAdapter,
KibanaRequest,
Expand Down
2 changes: 1 addition & 1 deletion src/core/server/http/logging/get_payload_size.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { createReadStream } from 'fs';
import { PassThrough } from 'stream';
import { createGunzip, createGzip } from 'zlib';

import { loggerMock, MockedLogger } from '../../logging/logger.mock';
import { loggerMock, MockedLogger } from '@kbn/logging-mocks';

import { getResponsePayloadBytes } from './get_payload_size';

Expand Down
2 changes: 1 addition & 1 deletion src/core/server/http/logging/get_payload_size.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { ReadStream } from 'fs';
import { Zlib } from 'zlib';
import { isBoom } from '@hapi/boom';
import type { Request } from '@hapi/hapi';
import { Logger } from '../../logging';
import type { Logger } from '@kbn/logging';

type Response = Request['response'];

Expand Down
2 changes: 1 addition & 1 deletion src/core/server/http/logging/get_response_log.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import type { Request } from '@hapi/hapi';
import Boom from '@hapi/boom';
import { loggerMock, MockedLogger } from '../../logging/logger.mock';
import { loggerMock, MockedLogger } from '@kbn/logging-mocks';
import { getEcsResponseLog } from './get_response_log';

jest.mock('./get_payload_size', () => ({
Expand Down
3 changes: 1 addition & 2 deletions src/core/server/http/logging/get_response_log.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ import querystring from 'querystring';
import { isBoom } from '@hapi/boom';
import type { Request } from '@hapi/hapi';
import numeral from '@elastic/numeral';
import { LogMeta } from '@kbn/logging';
import { Logger } from '../../logging';
import type { LogMeta, Logger } from '@kbn/logging';
import { getResponsePayloadBytes } from './get_payload_size';
import type { KibanaRequestState } from '../router';

Expand Down
2 changes: 1 addition & 1 deletion src/core/server/http/router/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { Request, ResponseObject, ResponseToolkit } from '@hapi/hapi';
import Boom from '@hapi/boom';

import { isConfigSchema } from '@kbn/config-schema';
import { Logger } from '../../logging';
import type { Logger } from '@kbn/logging';
import {
isUnauthorizedError as isElasticsearchUnauthorizedError,
UnauthorizedError as EsNotAuthorizedError,
Expand Down
2 changes: 1 addition & 1 deletion src/core/server/http_resources/http_resources_service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
* Side Public License, v 1.
*/

import type { Logger } from '@kbn/logging';
import { RequestHandlerContext } from '..';

import { CoreContext } from '../core_context';
Expand All @@ -18,7 +19,6 @@ import {
InternalHttpServicePreboot,
} from '../http';

import { Logger } from '../logging';
import { InternalRenderingServicePreboot, InternalRenderingServiceSetup } from '../rendering';
import { CoreService } from '../../types';

Expand Down
2 changes: 1 addition & 1 deletion src/core/server/i18n/i18n_service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*/

import { firstValueFrom } from 'rxjs';
import { Logger } from '../logging';
import type { Logger } from '@kbn/logging';
import { IConfigService } from '../config';
import { CoreContext } from '../core_context';
import { InternalHttpServicePreboot, InternalHttpServiceSetup } from '../http';
Expand Down
12 changes: 7 additions & 5 deletions src/core/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,12 @@ export type {
} from './http_resources';

export type { IRenderOptions } from './rendering';
export type {
LoggingServiceSetup,
LoggerContextConfigInput,
LoggerConfigType,
AppenderConfigType,
} from './logging';
export type {
Logger,
LoggerFactory,
Expand All @@ -253,11 +259,7 @@ export type {
LogMeta,
LogRecord,
LogLevel,
LoggingServiceSetup,
LoggerContextConfigInput,
LoggerConfigType,
AppenderConfigType,
} from './logging';
} from '@kbn/logging';

export { PluginType } from './plugins';

Expand Down
Loading

0 comments on commit a044026

Please sign in to comment.