Skip to content

Commit

Permalink
Export config schema
Browse files Browse the repository at this point in the history
  • Loading branch information
joshdover committed Jun 23, 2020
1 parent 1070e52 commit d623ad1
Show file tree
Hide file tree
Showing 5 changed files with 99 additions and 4 deletions.
12 changes: 11 additions & 1 deletion src/core/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,12 @@ import { CapabilitiesSetup, CapabilitiesStart } from './capabilities';
import { UuidServiceSetup } from './uuid';
import { MetricsServiceSetup } from './metrics';
import { StatusServiceSetup } from './status';
import { LoggingServiceSetup } from './logging';
import {
LoggingServiceSetup,
appendersSchema,
loggerContextConfigSchema,
loggerSchema,
} from './logging';

export { bootstrap } from './bootstrap';
export { Capabilities, CapabilitiesProvider, CapabilitiesSwitcher } from './capabilities';
Expand Down Expand Up @@ -463,4 +468,9 @@ export const config = {
elasticsearch: {
schema: elasticsearchConfigSchema,
},
logging: {
appenders: appendersSchema,
loggers: loggerSchema,
loggerContext: loggerContextConfigSchema,
},
};
8 changes: 7 additions & 1 deletion src/core/server/logging/appenders/appenders.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,13 @@ import { LogRecord } from '../log_record';
import { ConsoleAppender } from './console/console_appender';
import { FileAppender } from './file/file_appender';

const appendersSchema = schema.oneOf([
/**
* Config schema for validting the shape of the `appenders` key in in {@link LoggerContextConfigType} or
* {@link LoggingConfigType}.
*
* @public
*/
export const appendersSchema = schema.oneOf([
ConsoleAppender.configSchema,
FileAppender.configSchema,
LegacyAppender.configSchema,
Expand Down
4 changes: 3 additions & 1 deletion src/core/server/logging/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,13 @@ export {
LoggingConfigType,
LoggerContextConfigInput,
LoggerConfigType,
loggerContextConfigSchema,
loggerSchema,
} from './logging_config';
export { LoggingSystem, ILoggingSystem } from './logging_system';
export {
InternalLoggingServiceSetup,
LoggingServiceSetup,
LoggingService,
} from './logging_service';
export { AppenderConfigType } from './appenders/appenders';
export { appendersSchema, AppenderConfigType } from './appenders/appenders';
13 changes: 12 additions & 1 deletion src/core/server/logging/logging_config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,12 @@ const levelSchema = schema.oneOf(
}
);

const loggerSchema = schema.object({
/**
* Config schema for validating the `loggers` key in {@link LoggerContextConfigType} or {@link LoggingConfigType}.
*
* @public
*/
export const loggerSchema = schema.object({
appenders: schema.arrayOf(schema.string(), { defaultValue: [] }),
context: schema.string(),
level: levelSchema,
Expand Down Expand Up @@ -93,6 +98,12 @@ export const config = {

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

/**
* Config schema for validating the inputs to the {@link LoggingServiceStart.configure} API.
* See {@link LoggerContextConfigType}.
*
* @public
*/
export const loggerContextConfigSchema = schema.object({
appenders: schema.mapOf(schema.string(), Appenders.configSchema, {
defaultValue: new Map<string, AppenderConfigType>(),
Expand Down
66 changes: 66 additions & 0 deletions src/core/server/server.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -579,6 +579,72 @@ export const config: {
ignoreVersionMismatch: import("@kbn/config-schema/target/types/types").ConditionalType<false, boolean, boolean>;
}>;
};
logging: {
appenders: import("@kbn/config-schema").Type<Readonly<{} & {
layout: Readonly<{} & {
kind: "json";
}> | Readonly<{
pattern?: string | undefined;
highlight?: boolean | undefined;
} & {
kind: "pattern";
}>;
kind: "console";
}> | Readonly<{} & {
path: string;
layout: Readonly<{} & {
kind: "json";
}> | Readonly<{
pattern?: string | undefined;
highlight?: boolean | undefined;
} & {
kind: "pattern";
}>;
kind: "file";
}> | Readonly<{
legacyLoggingConfig?: any;
} & {
kind: "legacy-appender";
}>>;
loggers: import("@kbn/config-schema").ObjectType<{
appenders: import("@kbn/config-schema").Type<string[]>;
context: import("@kbn/config-schema").Type<string>;
level: import("@kbn/config-schema").Type<import("./logging/log_level").LogLevelId>;
}>;
loggerContext: import("@kbn/config-schema").ObjectType<{
appenders: import("@kbn/config-schema").Type<Map<string, Readonly<{} & {
layout: Readonly<{} & {
kind: "json";
}> | Readonly<{
pattern?: string | undefined;
highlight?: boolean | undefined;
} & {
kind: "pattern";
}>;
kind: "console";
}> | Readonly<{} & {
path: string;
layout: Readonly<{} & {
kind: "json";
}> | Readonly<{
pattern?: string | undefined;
highlight?: boolean | undefined;
} & {
kind: "pattern";
}>;
kind: "file";
}> | Readonly<{
legacyLoggingConfig?: any;
} & {
kind: "legacy-appender";
}>>>;
loggers: import("@kbn/config-schema").Type<Readonly<{} & {
context: string;
appenders: string[];
level: import("./logging/log_level").LogLevelId;
}>[]>;
}>;
};
};

// @public
Expand Down

0 comments on commit d623ad1

Please sign in to comment.