Skip to content

Commit

Permalink
Only log logging.json deprecation warnings when not in dev and only s…
Browse files Browse the repository at this point in the history
…et legacy logging level when not opted in to KP logging
  • Loading branch information
TinaHeiligers committed Mar 15, 2021
1 parent a389f4e commit b9011ff
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 20 deletions.
10 changes: 3 additions & 7 deletions packages/kbn-legacy-logging/src/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ const HANDLED_IN_KIBANA_PLATFORM = Joi.any().description(
* Set up logging from the platform logging instead
*/
export interface LegacyLoggingConfig {
silent: boolean; // support for cli args
quiet?: boolean; // deprecated
silent: boolean;
quiet?: boolean;
verbose: boolean;
events: Record<string, any>;
dest: string;
Expand All @@ -33,7 +33,7 @@ export interface LegacyLoggingConfig {
pollingInterval: number;
usePolling: boolean;
pollingPolicyTestTimeout?: number;
}; // all deprecated
};
}

export const legacyLoggingConfigSchema = Joi.object()
Expand All @@ -43,7 +43,6 @@ export const legacyLoggingConfigSchema = Joi.object()
root: HANDLED_IN_KIBANA_PLATFORM,

silent: Joi.boolean().default(false),
// deprecated
quiet: Joi.boolean().when('silent', {
is: true,
then: Joi.boolean().default(true).valid(true),
Expand All @@ -55,17 +54,14 @@ export const legacyLoggingConfigSchema = Joi.object()
otherwise: Joi.boolean().default(false),
}),
events: Joi.any().default({}),
// deprecated
dest: Joi.string().default('stdout'),
filter: Joi.any().default({}),
// deprecated
json: Joi.boolean().when('dest', {
is: 'stdout',
then: Joi.boolean().default(!process.stdout.isTTY),
otherwise: Joi.boolean().default(true),
}),
timezone: Joi.string(),
// deprecated
rotate: Joi.object()
.keys({
enabled: Joi.boolean().default(false),
Expand Down
14 changes: 6 additions & 8 deletions src/cli/serve/serve.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,19 +112,17 @@ 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); // deprecated

// retain support for cli flag `--silent`
if (opts.silent) {
// set('logging.level', 'off') && set('logging.root.level', 'off');
set('logging.silent', true) && set('logging.root.level', 'off');
}
// retain support for cli flag `--verbose`
if (opts.verbose) {
// set('logging.level', 'all') && set('logging.root.level', 'all');
set('logging.verbose', true) && set('logging.root.level', 'all');
// Only set logging.verbose to true when KP logging isn't configured.
if (!has('rawConfig.logging.root.appenders')) {
set('logging.verbose', true);
} else {
set('logging.root.level', 'all');
}
}
// if (opts.logFile) set('logging.dest', opts.logFile); // deprecated

set('plugins.scanDirs', _.compact([].concat(get('plugins.scanDirs'), opts.pluginDir)));
set('plugins.paths', _.compact([].concat(get('plugins.paths'), opts.pluginPath)));
Expand Down
12 changes: 7 additions & 5 deletions src/core/server/config/deprecation/core_deprecations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,11 +182,13 @@ const verboseLoggingDeprecation: ConfigDeprecation = (settings, fromPath, log) =
};

const jsonLoggingDeprecation: ConfigDeprecation = (settings, fromPath, log) => {
if (has(settings, 'logging.json')) {
if (has(settings, 'logging.json') && settings.env !== 'development') {
log(
'"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 ' +
'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/elastic/kibana/blob/master/src/core/server/logging/README.mdx.'
);
}
Expand All @@ -202,9 +204,9 @@ const logRotateDeprecation: ConfigDeprecation = (settings, fromPath, log) => {
has(settings, 'logging.rotate.keepFiles')
) {
log(
'"logging.rotate" and sub-options have been deprecated and will be removed in 8.0. Moving forward, you can enabled ' +
'log rotation using the "rolling-file" appender for a context in your logging configuration. ' +
'For more details, see ' +
'"logging.rotate" and sub-options have been deprecated and will be removed in 8.0. ' +
'Moving forward, you can enabled log rotation using the "rolling-file" appender for a context ' +
'in your logging configuration. For more details, see ' +
'https://github.com/elastic/kibana/blob/master/src/core/server/logging/README.mdx#rolling-file-appender'
);
}
Expand Down

0 comments on commit b9011ff

Please sign in to comment.