Skip to content

Commit

Permalink
[core.logging] Deprecates legacy logging dest, json, verbosity and ro…
Browse files Browse the repository at this point in the history
…tate configurations (#94238) (#94878)

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
# Conflicts:
#	docs/migration/migrate_8_0.asciidoc
#	src/core/server/config/deprecation/core_deprecations.ts
  • Loading branch information
TinaHeiligers authored Mar 18, 2021
1 parent 09b5404 commit 6f38b96
Show file tree
Hide file tree
Showing 11 changed files with 333 additions and 62 deletions.
5 changes: 3 additions & 2 deletions packages/kbn-config/src/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@ export interface EnvOptions {
export interface CliArgs {
dev: boolean;
envName?: string;
quiet: boolean;
silent: boolean;
/** @deprecated */
quiet?: boolean;
silent?: boolean;
watch: boolean;
basePath: boolean;
oss: boolean;
Expand Down
9 changes: 6 additions & 3 deletions packages/kbn-legacy-logging/src/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,12 @@ import Joi from 'joi';
const HANDLED_IN_KIBANA_PLATFORM = Joi.any().description(
'This key is handled in the new platform ONLY'
);

/**
* @deprecated
*
* Legacy logging has been deprecated and will be removed in 8.0.
* Set up logging from the platform logging instead
*/
export interface LegacyLoggingConfig {
silent: boolean;
quiet: boolean;
Expand All @@ -38,13 +43,11 @@ export const legacyLoggingConfigSchema = Joi.object()
root: HANDLED_IN_KIBANA_PLATFORM,

silent: Joi.boolean().default(false),

quiet: Joi.boolean().when('silent', {
is: true,
then: Joi.boolean().default(true).valid(true),
otherwise: Joi.boolean().default(false),
}),

verbose: Joi.boolean().when('quiet', {
is: true,
then: Joi.valid(false).default(false),
Expand Down
25 changes: 18 additions & 7 deletions src/cli/serve/serve.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ function applyConfigOverrides(rawConfig, opts, extraCliOptions) {
const get = _.partial(_.get, rawConfig);
const has = _.partial(_.has, rawConfig);
const merge = _.partial(_.merge, rawConfig);

if (opts.oss) {
delete rawConfig.xpack;
}
Expand Down Expand Up @@ -112,10 +111,18 @@ function applyConfigOverrides(rawConfig, opts, extraCliOptions) {
if (opts.elasticsearch) set('elasticsearch.hosts', opts.elasticsearch.split(','));
if (opts.port) set('server.port', opts.port);
if (opts.host) set('server.host', opts.host);
if (opts.quiet) set('logging.quiet', true);
if (opts.silent) set('logging.silent', true);
if (opts.verbose) set('logging.verbose', true);
if (opts.logFile) set('logging.dest', opts.logFile);
if (opts.silent) {
set('logging.silent', true);
set('logging.root.level', 'off');
}
if (opts.verbose) {
if (has('logging.root.appenders')) {
set('logging.root.level', 'all');
} else {
// Only set logging.verbose to true for legacy logging when KP logging isn't configured.
set('logging.verbose', true);
}
}

set('plugins.scanDirs', _.compact([].concat(get('plugins.scanDirs'), opts.pluginDir)));
set('plugins.paths', _.compact([].concat(get('plugins.paths'), opts.pluginPath)));
Expand All @@ -140,11 +147,14 @@ export default function (program) {
[getConfigPath()]
)
.option('-p, --port <port>', 'The port to bind to', parseInt)
.option('-q, --quiet', 'Prevent all logging except errors')
.option('-q, --quiet', 'Deprecated, set logging level in your configuration')
.option('-Q, --silent', 'Prevent all logging')
.option('--verbose', 'Turns on verbose logging')
.option('-H, --host <host>', 'The host to bind to')
.option('-l, --log-file <path>', 'The file to log to')
.option(
'-l, --log-file <path>',
'Deprecated, set logging file destination in your configuration'
)
.option(
'--plugin-dir <path>',
'A path to scan for plugins, this can be specified multiple ' +
Expand Down Expand Up @@ -204,6 +214,7 @@ export default function (program) {
cliArgs: {
dev: !!opts.dev,
envName: unknownOptions.env ? unknownOptions.env.name : undefined,
// no longer supported
quiet: !!opts.quiet,
silent: !!opts.silent,
watch: !!opts.watch,
Expand Down
186 changes: 165 additions & 21 deletions src/core/server/config/deprecation/core_deprecations.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -264,17 +264,10 @@ describe('core deprecations', () => {
});
expect(messages).toMatchInlineSnapshot(`
Array [
"\\"logging.events.ops\\" has been deprecated and will be removed in 8.0. To access ops data moving forward, please enable debug logs for the \\"metrics.ops\\" context in your logging configuration. For more details, see https://github.com/elastic/kibana/blob/master/src/core/server/logging/README.md",
"\\"logging.events.ops\\" has been deprecated and will be removed in 8.0. To access ops data moving forward, please enable debug logs for the \\"metrics.ops\\" context in your logging configuration. For more details, see https://github.com/elastic/kibana/blob/master/src/core/server/logging/README.mdx",
]
`);
});

it('does not warn when other events are configured', () => {
const { messages } = applyCoreDeprecations({
logging: { events: { log: '*' } },
});
expect(messages).toEqual([]);
});
});

describe('logging.events.request and logging.events.response', () => {
Expand All @@ -284,7 +277,7 @@ describe('core deprecations', () => {
});
expect(messages).toMatchInlineSnapshot(`
Array [
"\\"logging.events.request\\" and \\"logging.events.response\\" have been deprecated and will be removed in 8.0. To access request and/or response data moving forward, please enable debug logs for the \\"http.server.response\\" context in your logging configuration. For more details, see https://github.com/elastic/kibana/blob/master/src/core/server/logging/README.md",
"\\"logging.events.request\\" and \\"logging.events.response\\" have been deprecated and will be removed in 8.0. To access request and/or response data moving forward, please enable debug logs for the \\"http.server.response\\" context in your logging configuration. For more details, see https://github.com/elastic/kibana/blob/master/src/core/server/logging/README.mdx",
]
`);
});
Expand All @@ -295,7 +288,7 @@ describe('core deprecations', () => {
});
expect(messages).toMatchInlineSnapshot(`
Array [
"\\"logging.events.request\\" and \\"logging.events.response\\" have been deprecated and will be removed in 8.0. To access request and/or response data moving forward, please enable debug logs for the \\"http.server.response\\" context in your logging configuration. For more details, see https://github.com/elastic/kibana/blob/master/src/core/server/logging/README.md",
"\\"logging.events.request\\" and \\"logging.events.response\\" have been deprecated and will be removed in 8.0. To access request and/or response data moving forward, please enable debug logs for the \\"http.server.response\\" context in your logging configuration. For more details, see https://github.com/elastic/kibana/blob/master/src/core/server/logging/README.mdx",
]
`);
});
Expand All @@ -306,36 +299,187 @@ describe('core deprecations', () => {
});
expect(messages).toMatchInlineSnapshot(`
Array [
"\\"logging.events.request\\" and \\"logging.events.response\\" have been deprecated and will be removed in 8.0. To access request and/or response data moving forward, please enable debug logs for the \\"http.server.response\\" context in your logging configuration. For more details, see https://github.com/elastic/kibana/blob/master/src/core/server/logging/README.md",
"\\"logging.events.request\\" and \\"logging.events.response\\" have been deprecated and will be removed in 8.0. To access request and/or response data moving forward, please enable debug logs for the \\"http.server.response\\" context in your logging configuration. For more details, see https://github.com/elastic/kibana/blob/master/src/core/server/logging/README.mdx",
]
`);
});
});

it('does not warn when other events are configured', () => {
describe('logging.timezone', () => {
it('warns when ops events are used', () => {
const { messages } = applyCoreDeprecations({
logging: { events: { log: '*' } },
logging: { timezone: 'GMT' },
});
expect(messages).toEqual([]);
expect(messages).toMatchInlineSnapshot(`
Array [
"\\"logging.timezone\\" has been deprecated and will be removed in 8.0. To set the timezone moving forward, please add a timezone date modifier to the log pattern in your logging configuration. For more details, see https://github.com/elastic/kibana/blob/master/src/core/server/logging/README.mdx",
]
`);
});
});

describe('logging.timezone', () => {
it('warns when ops events are used', () => {
describe('logging.dest', () => {
it('warns when dest is used', () => {
const { messages } = applyCoreDeprecations({
logging: { timezone: 'GMT' },
logging: { dest: 'stdout' },
});
expect(messages).toMatchInlineSnapshot(`
Array [
"\\"logging.dest\\" has been deprecated and will be removed in 8.0. To set the destination moving forward, you can use the \\"console\\" appender in your logging configuration or define a custom one. For more details, see https://github.com/elastic/kibana/blob/master/src/core/server/logging/README.mdx.",
]
`);
});
it('warns when dest path is given', () => {
const { messages } = applyCoreDeprecations({
logging: { dest: '/log-log.txt' },
});
expect(messages).toMatchInlineSnapshot(`
Array [
"\\"logging.dest\\" has been deprecated and will be removed in 8.0. To set the destination moving forward, you can use the \\"console\\" appender in your logging configuration or define a custom one. For more details, see https://github.com/elastic/kibana/blob/master/src/core/server/logging/README.mdx.",
]
`);
});
});

describe('logging.quiet, logging.silent and logging.verbose', () => {
it('warns when quiet is used', () => {
const { messages } = applyCoreDeprecations({
logging: { quiet: true },
});
expect(messages).toMatchInlineSnapshot(`
Array [
"\\"logging.quiet\\" has been deprecated and will be removed in 8.0. Moving forward, you can use \\"logging.root.level:error\\" in your logging configuration. ",
]
`);
});
it('warns when silent is used', () => {
const { messages } = applyCoreDeprecations({
logging: { silent: true },
});
expect(messages).toMatchInlineSnapshot(`
Array [
"\\"logging.silent\\" has been deprecated and will be removed in 8.0. Moving forward, you can use \\"logging.root.level:off\\" in your logging configuration. ",
]
`);
});
it('warns when verbose is used', () => {
const { messages } = applyCoreDeprecations({
logging: { verbose: true },
});
expect(messages).toMatchInlineSnapshot(`
Array [
"\\"logging.verbose\\" has been deprecated and will be removed in 8.0. Moving forward, you can use \\"logging.root.level:all\\" in your logging configuration. ",
]
`);
});
});

describe('logging.json', () => {
it('warns when json is used', () => {
const { messages } = applyCoreDeprecations({
logging: { json: true },
});
expect(messages).toMatchInlineSnapshot(`
Array [
"\\"logging.json\\" has been deprecated and will be removed in 8.0. To specify log message format moving forward, you can configure the \\"appender.layout\\" property for every custom appender in your logging configuration. There is currently no default layout for custom appenders and each one must be declared explicitly. For more details, see https://github.com/elastic/kibana/blob/master/src/core/server/logging/README.mdx.",
]
`);
});
});

describe('logging.rotate.enabled, logging.rotate.usePolling, logging.rotate.pollingInterval, logging.rotate.everyBytes and logging.rotate.keepFiles', () => {
it('warns when logging.rotate configurations are used', () => {
const { messages } = applyCoreDeprecations({
logging: { rotate: { enabled: true } },
});
expect(messages).toMatchInlineSnapshot(`
Array [
"\\"logging.rotate\\" and sub-options have been deprecated and will be removed in 8.0. Moving forward, you can enable log rotation using the \\"rolling-file\\" appender for a logger in your logging configuration. For more details, see https://github.com/elastic/kibana/blob/master/src/core/server/logging/README.mdx#rolling-file-appender",
]
`);
});

it('warns when logging.rotate polling configurations are used', () => {
const { messages } = applyCoreDeprecations({
logging: { rotate: { enabled: true, usePolling: true, pollingInterval: 5000 } },
});
expect(messages).toMatchInlineSnapshot(`
Array [
"\\"logging.rotate\\" and sub-options have been deprecated and will be removed in 8.0. Moving forward, you can enable log rotation using the \\"rolling-file\\" appender for a logger in your logging configuration. For more details, see https://github.com/elastic/kibana/blob/master/src/core/server/logging/README.mdx#rolling-file-appender",
]
`);
});

it('warns when logging.rotate.everyBytes configurations are used', () => {
const { messages } = applyCoreDeprecations({
logging: { rotate: { enabled: true, everyBytes: 1048576 } },
});
expect(messages).toMatchInlineSnapshot(`
Array [
"\\"logging.timezone\\" has been deprecated and will be removed in 8.0. To set the timezone moving forward, please add a timezone date modifier to the log pattern in your logging configuration. For more details, see https://github.com/elastic/kibana/blob/master/src/core/server/logging/README.md",
"\\"logging.rotate\\" and sub-options have been deprecated and will be removed in 8.0. Moving forward, you can enable log rotation using the \\"rolling-file\\" appender for a logger in your logging configuration. For more details, see https://github.com/elastic/kibana/blob/master/src/core/server/logging/README.mdx#rolling-file-appender",
]
`);
});

it('does not warn when other events are configured', () => {
it('warns when logging.rotate.keepFiles is used', () => {
const { messages } = applyCoreDeprecations({
logging: { events: { log: '*' } },
logging: { rotate: { enabled: true, keepFiles: 1024 } },
});
expect(messages).toEqual([]);
expect(messages).toMatchInlineSnapshot(`
Array [
"\\"logging.rotate\\" and sub-options have been deprecated and will be removed in 8.0. Moving forward, you can enable log rotation using the \\"rolling-file\\" appender for a logger in your logging configuration. For more details, see https://github.com/elastic/kibana/blob/master/src/core/server/logging/README.mdx#rolling-file-appender",
]
`);
});
});

describe('logging.events.log', () => {
it('warns when events.log is used', () => {
const { messages } = applyCoreDeprecations({
logging: { events: { log: ['info'] } },
});
expect(messages).toMatchInlineSnapshot(`
Array [
"\\"logging.events.log\\" has been deprecated and will be removed in 8.0. Moving forward, log levels can be customized on a per-logger basis using the new logging configuration. ",
]
`);
});
});

describe('logging.events.error', () => {
it('warns when events.error is used', () => {
const { messages } = applyCoreDeprecations({
logging: { events: { error: ['some error'] } },
});
expect(messages).toMatchInlineSnapshot(`
Array [
"\\"logging.events.error\\" has been deprecated and will be removed in 8.0. Moving forward, you can use \\"logging.root.level: error\\" in your logging configuration. ",
]
`);
});
});

describe('logging.filter', () => {
it('warns when filter.cookie is used', () => {
const { messages } = applyCoreDeprecations({
logging: { filter: { cookie: 'none' } },
});
expect(messages).toMatchInlineSnapshot(`
Array [
"\\"logging.filter\\" has been deprecated and will be removed in 8.0. ",
]
`);
});

it('warns when filter.authorization is used', () => {
const { messages } = applyCoreDeprecations({
logging: { filter: { authorization: 'none' } },
});
expect(messages).toMatchInlineSnapshot(`
Array [
"\\"logging.filter\\" has been deprecated and will be removed in 8.0. ",
]
`);
});
});
});
Loading

0 comments on commit 6f38b96

Please sign in to comment.