Skip to content

Commit d623ad1

Browse files
committed
Export config schema
1 parent 1070e52 commit d623ad1

File tree

5 files changed

+99
-4
lines changed

5 files changed

+99
-4
lines changed

src/core/server/index.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,12 @@ import { CapabilitiesSetup, CapabilitiesStart } from './capabilities';
6262
import { UuidServiceSetup } from './uuid';
6363
import { MetricsServiceSetup } from './metrics';
6464
import { StatusServiceSetup } from './status';
65-
import { LoggingServiceSetup } from './logging';
65+
import {
66+
LoggingServiceSetup,
67+
appendersSchema,
68+
loggerContextConfigSchema,
69+
loggerSchema,
70+
} from './logging';
6671

6772
export { bootstrap } from './bootstrap';
6873
export { Capabilities, CapabilitiesProvider, CapabilitiesSwitcher } from './capabilities';
@@ -463,4 +468,9 @@ export const config = {
463468
elasticsearch: {
464469
schema: elasticsearchConfigSchema,
465470
},
471+
logging: {
472+
appenders: appendersSchema,
473+
loggers: loggerSchema,
474+
loggerContext: loggerContextConfigSchema,
475+
},
466476
};

src/core/server/logging/appenders/appenders.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,13 @@ import { LogRecord } from '../log_record';
2626
import { ConsoleAppender } from './console/console_appender';
2727
import { FileAppender } from './file/file_appender';
2828

29-
const appendersSchema = schema.oneOf([
29+
/**
30+
* Config schema for validting the shape of the `appenders` key in in {@link LoggerContextConfigType} or
31+
* {@link LoggingConfigType}.
32+
*
33+
* @public
34+
*/
35+
export const appendersSchema = schema.oneOf([
3036
ConsoleAppender.configSchema,
3137
FileAppender.configSchema,
3238
LegacyAppender.configSchema,

src/core/server/logging/index.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,13 @@ export {
2626
LoggingConfigType,
2727
LoggerContextConfigInput,
2828
LoggerConfigType,
29+
loggerContextConfigSchema,
30+
loggerSchema,
2931
} from './logging_config';
3032
export { LoggingSystem, ILoggingSystem } from './logging_system';
3133
export {
3234
InternalLoggingServiceSetup,
3335
LoggingServiceSetup,
3436
LoggingService,
3537
} from './logging_service';
36-
export { AppenderConfigType } from './appenders/appenders';
38+
export { appendersSchema, AppenderConfigType } from './appenders/appenders';

src/core/server/logging/logging_config.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,12 @@ const levelSchema = schema.oneOf(
5555
}
5656
);
5757

58-
const loggerSchema = schema.object({
58+
/**
59+
* Config schema for validating the `loggers` key in {@link LoggerContextConfigType} or {@link LoggingConfigType}.
60+
*
61+
* @public
62+
*/
63+
export const loggerSchema = schema.object({
5964
appenders: schema.arrayOf(schema.string(), { defaultValue: [] }),
6065
context: schema.string(),
6166
level: levelSchema,
@@ -93,6 +98,12 @@ export const config = {
9398

9499
export type LoggingConfigType = TypeOf<typeof config.schema>;
95100

101+
/**
102+
* Config schema for validating the inputs to the {@link LoggingServiceStart.configure} API.
103+
* See {@link LoggerContextConfigType}.
104+
*
105+
* @public
106+
*/
96107
export const loggerContextConfigSchema = schema.object({
97108
appenders: schema.mapOf(schema.string(), Appenders.configSchema, {
98109
defaultValue: new Map<string, AppenderConfigType>(),

src/core/server/server.api.md

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -579,6 +579,72 @@ export const config: {
579579
ignoreVersionMismatch: import("@kbn/config-schema/target/types/types").ConditionalType<false, boolean, boolean>;
580580
}>;
581581
};
582+
logging: {
583+
appenders: import("@kbn/config-schema").Type<Readonly<{} & {
584+
layout: Readonly<{} & {
585+
kind: "json";
586+
}> | Readonly<{
587+
pattern?: string | undefined;
588+
highlight?: boolean | undefined;
589+
} & {
590+
kind: "pattern";
591+
}>;
592+
kind: "console";
593+
}> | Readonly<{} & {
594+
path: string;
595+
layout: Readonly<{} & {
596+
kind: "json";
597+
}> | Readonly<{
598+
pattern?: string | undefined;
599+
highlight?: boolean | undefined;
600+
} & {
601+
kind: "pattern";
602+
}>;
603+
kind: "file";
604+
}> | Readonly<{
605+
legacyLoggingConfig?: any;
606+
} & {
607+
kind: "legacy-appender";
608+
}>>;
609+
loggers: import("@kbn/config-schema").ObjectType<{
610+
appenders: import("@kbn/config-schema").Type<string[]>;
611+
context: import("@kbn/config-schema").Type<string>;
612+
level: import("@kbn/config-schema").Type<import("./logging/log_level").LogLevelId>;
613+
}>;
614+
loggerContext: import("@kbn/config-schema").ObjectType<{
615+
appenders: import("@kbn/config-schema").Type<Map<string, Readonly<{} & {
616+
layout: Readonly<{} & {
617+
kind: "json";
618+
}> | Readonly<{
619+
pattern?: string | undefined;
620+
highlight?: boolean | undefined;
621+
} & {
622+
kind: "pattern";
623+
}>;
624+
kind: "console";
625+
}> | Readonly<{} & {
626+
path: string;
627+
layout: Readonly<{} & {
628+
kind: "json";
629+
}> | Readonly<{
630+
pattern?: string | undefined;
631+
highlight?: boolean | undefined;
632+
} & {
633+
kind: "pattern";
634+
}>;
635+
kind: "file";
636+
}> | Readonly<{
637+
legacyLoggingConfig?: any;
638+
} & {
639+
kind: "legacy-appender";
640+
}>>>;
641+
loggers: import("@kbn/config-schema").Type<Readonly<{} & {
642+
context: string;
643+
appenders: string[];
644+
level: import("./logging/log_level").LogLevelId;
645+
}>[]>;
646+
}>;
647+
};
582648
};
583649

584650
// @public

0 commit comments

Comments
 (0)