Skip to content

Commit

Permalink
Adds deprecation warnings for legacy logging.event.log and logging.ev…
Browse files Browse the repository at this point in the history
…ent.error configuration
  • Loading branch information
TinaHeiligers committed Mar 17, 2021
1 parent 84cf8fe commit f1e901d
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 21 deletions.
47 changes: 26 additions & 21 deletions src/core/server/config/deprecation/core_deprecations.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -248,13 +248,6 @@ describe('core deprecations', () => {
]
`);
});

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 Down Expand Up @@ -290,13 +283,6 @@ describe('core deprecations', () => {
]
`);
});

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

describe('logging.timezone', () => {
Expand All @@ -310,13 +296,6 @@ describe('core deprecations', () => {
]
`);
});

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

describe('logging.dest', () => {
Expand Down Expand Up @@ -433,4 +412,30 @@ describe('core deprecations', () => {
`);
});
});

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, you can use \\"logging.root.level\\" in your 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. ",
]
`);
});
});
});
22 changes: 22 additions & 0 deletions src/core/server/config/deprecation/core_deprecations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,26 @@ const logRotateDeprecation: ConfigDeprecation = (settings, fromPath, log) => {
return settings;
};

const logEventsLogDeprecation: ConfigDeprecation = (settings, fromPath, log) => {
if (has(settings, 'logging.events.log')) {
log(
'"logging.events.log" has been deprecated and will be removed ' +
'in 8.0. Moving forward, you can use "logging.root.level" in your logging configuration. '
);
}
return settings;
};

const logEventsErrorDeprecation: ConfigDeprecation = (settings, fromPath, log) => {
if (has(settings, 'logging.events.error')) {
log(
'"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. '
);
}
return settings;
};

export const coreDeprecationProvider: ConfigDeprecationProvider = ({ rename, unusedFromRoot }) => [
unusedFromRoot('savedObjects.indexCheckTimeout'),
unusedFromRoot('server.xsrf.token'),
Expand Down Expand Up @@ -256,4 +276,6 @@ export const coreDeprecationProvider: ConfigDeprecationProvider = ({ rename, unu
verboseLoggingDeprecation,
jsonLoggingDeprecation,
logRotateDeprecation,
logEventsLogDeprecation,
logEventsErrorDeprecation,
];

0 comments on commit f1e901d

Please sign in to comment.