From 862c5a3b4e7b31a286fdafdcbab4da5bd9f464aa Mon Sep 17 00:00:00 2001 From: Rahul Gautam Singh Date: Wed, 15 May 2024 20:43:35 +0545 Subject: [PATCH 1/6] drop logFile and logFileLevel --- docs/usage/self-hosted-configuration.md | 4 --- lib/config/options/index.ts | 19 ------------- lib/config/types.ts | 3 --- lib/config/validation.spec.ts | 11 ++++---- lib/config/validation.ts | 2 -- lib/workers/global/config/parse/index.spec.ts | 27 +++---------------- lib/workers/global/config/parse/index.ts | 23 ++-------------- 7 files changed, 11 insertions(+), 78 deletions(-) diff --git a/docs/usage/self-hosted-configuration.md b/docs/usage/self-hosted-configuration.md index dae523fe708f87..041494cd415411 100644 --- a/docs/usage/self-hosted-configuration.md +++ b/docs/usage/self-hosted-configuration.md @@ -751,10 +751,6 @@ When you set `inheritConfigStrict=true` then Renovate will abort the run and rai `logContext` is included with each log entry only if `logFormat="json"` - it is not included in the pretty log output. If left as default (null), a random short ID will be selected. -## logFile - -## logFileLevel - ## migratePresets Use this if you have repositories that extend from a particular preset, which has now been renamed or removed. diff --git a/lib/config/options/index.ts b/lib/config/options/index.ts index 4de6fcf15604e1..c04f77abe37581 100644 --- a/lib/config/options/index.ts +++ b/lib/config/options/index.ts @@ -520,25 +520,6 @@ const options: RenovateOptions[] = [ supportedManagers: ['gomod'], }, // Log options - { - name: 'logFile', - description: 'Log file path.', - stage: 'global', - type: 'string', - globalOnly: true, - deprecationMsg: - 'Instead of configuring log file path in the file config. Use the `LOG_FILE` environment variable instead.', - }, - { - name: 'logFileLevel', - description: 'Set the log file log level.', - stage: 'global', - type: 'string', - default: 'debug', - globalOnly: true, - deprecationMsg: - 'Instead of configuring log file level in the file config. Use the `LOG_FILE_LEVEL` environment variable instead.', - }, { name: 'logContext', description: 'Add a global or per-repo log context to each log entry.', diff --git a/lib/config/types.ts b/lib/config/types.ts index 9a1ded16b00418..7f92b94b8b5364 100644 --- a/lib/config/types.ts +++ b/lib/config/types.ts @@ -1,4 +1,3 @@ -import type { LogLevel } from 'bunyan'; import type { PlatformId } from '../constants'; import type { LogLevelRemap } from '../logger/types'; import type { CustomManager } from '../modules/manager/custom/types'; @@ -114,8 +113,6 @@ export interface GlobalOnlyConfig { gitNoVerify?: GitNoVerifyOption[]; gitPrivateKey?: string; globalExtends?: string[]; - logFile?: string; - logFileLevel?: LogLevel; platform?: PlatformId; prCommitsPerRunLimit?: number; privateKeyPath?: string; diff --git a/lib/config/validation.spec.ts b/lib/config/validation.spec.ts index b312eb1b33ef7c..9cdc380ca06332 100644 --- a/lib/config/validation.spec.ts +++ b/lib/config/validation.spec.ts @@ -1261,19 +1261,18 @@ describe('config/validation', () => { }); describe('validateConfig() -> globaOnly options', () => { - it('returns deprecation warnings', async () => { + it('returns invalid option warnings', async () => { const config = { logFile: 'something', }; - const { warnings } = await configValidation.validateConfig( + const { errors } = await configValidation.validateConfig( 'global', config, ); - expect(warnings).toMatchObject([ + expect(errors).toMatchObject([ { - message: - 'Using logFile to specify log file name is deprecated now. Please use the enviroment variable LOG_FILE instead', - topic: 'Deprecation Warning', + message: 'Invalid configuration option: logFile', + topic: 'Configuration Error', }, ]); }); diff --git a/lib/config/validation.ts b/lib/config/validation.ts index 72ac36ddb55af3..092b629665581e 100644 --- a/lib/config/validation.ts +++ b/lib/config/validation.ts @@ -98,8 +98,6 @@ function getDeprecationMessage(option: string): string | undefined { branchName: `Direct editing of branchName is now deprecated. Please edit branchPrefix, additionalBranchPrefix, or branchTopic instead`, commitMessage: `Direct editing of commitMessage is now deprecated. Please edit commitMessage's subcomponents instead.`, prTitle: `Direct editing of prTitle is now deprecated. Please edit commitMessage subcomponents instead as they will be passed through to prTitle.`, - logFile: `Using logFile to specify log file name is deprecated now. Please use the enviroment variable LOG_FILE instead`, - logFileLevel: `Using logFileLevel to specify log level for file logging is deprecated now. Please use the enviroment variable LOG_FILE_LEVEL instead`, }; return deprecatedOptions[option]; } diff --git a/lib/workers/global/config/parse/index.spec.ts b/lib/workers/global/config/parse/index.spec.ts index d13081cc8f9440..f8d7936da73c7a 100644 --- a/lib/workers/global/config/parse/index.spec.ts +++ b/lib/workers/global/config/parse/index.spec.ts @@ -173,30 +173,11 @@ describe('workers/global/config/parse/index', () => { expect(parsed).toContainEntries([['dryRun', null]]); }); - it('initalizes file logging when logFile is set and env vars LOG_FILE is undefined', async () => { - jest.doMock( - '../../../../../config.js', - () => ({ logFile: 'somepath', logFileLevel: 'debug' }), - { - virtual: true, - }, - ); - const env: NodeJS.ProcessEnv = {}; - const parsedConfig = await configParser.parseConfigs(env, defaultArgv); - expect(parsedConfig).not.toContain([['logFile', 'someFile']]); - expect(getParentDir).toHaveBeenCalledWith('somepath'); - }); - - it('skips initializing file logging when logFile is set but env vars LOG_FILE is defined', async () => { - jest.doMock( - '../../../../../config.js', - () => ({ logFile: 'somepath', logFileLevel: 'debug' }), - { - virtual: true, - }, - ); + it('does not initalize file when env var LOG_FILE is undefined', async () => { + jest.doMock('../../../../../config.js', () => ({}), { + virtual: true, + }); const env: NodeJS.ProcessEnv = {}; - process.env.LOG_FILE = 'somepath'; const parsedConfig = await configParser.parseConfigs(env, defaultArgv); expect(parsedConfig).not.toContain([['logFile', 'someFile']]); expect(getParentDir).not.toHaveBeenCalled(); diff --git a/lib/workers/global/config/parse/index.ts b/lib/workers/global/config/parse/index.ts index 6d51625ace451a..520321f681558a 100644 --- a/lib/workers/global/config/parse/index.ts +++ b/lib/workers/global/config/parse/index.ts @@ -1,11 +1,10 @@ -import is from '@sindresorhus/is'; import * as defaultsParser from '../../../../config/defaults'; import type { AllConfig } from '../../../../config/types'; import { mergeChildConfig } from '../../../../config/utils'; -import { addStream, logger, setContext } from '../../../../logger'; +import { logger, setContext } from '../../../../logger'; import { detectAllGlobalConfig } from '../../../../modules/manager'; import { coerceArray } from '../../../../util/array'; -import { ensureDir, getParentDir, readSystemFile } from '../../../../util/fs'; +import { readSystemFile } from '../../../../util/fs'; import { addSecretForSanitizing } from '../../../../util/sanitize'; import { ensureTrailingSlash } from '../../../../util/url'; import * as cliParser from './cli'; @@ -67,20 +66,6 @@ export async function parseConfigs( setContext(config.logContext); } - // Add file logger - if (config.logFile && is.undefined(process.env.LOG_FILE)) { - logger.debug( - // TODO: types (#22198) - `Enabling ${config.logFileLevel!} logging to ${config.logFile}`, - ); - await ensureDir(getParentDir(config.logFile)); - addStream({ - name: 'logfile', - path: config.logFile, - level: config.logFileLevel, - }); - } - logger.trace({ config: defaultConfig }, 'Default config'); logger.debug({ config: fileConfig }, 'File config'); logger.debug({ config: cliConfig }, 'CLI config'); @@ -119,9 +104,5 @@ export async function parseConfigs( config.onboardingNoDeps = 'enabled'; } - // Remove log file entries - delete config.logFile; - delete config.logFileLevel; - return config; } From 9acf99ba552be5c1f3f0c728c9a3b288363daad3 Mon Sep 17 00:00:00 2001 From: Rahul Gautam Singh Date: Wed, 15 May 2024 20:44:18 +0545 Subject: [PATCH 2/6] refactor --- lib/workers/global/config/parse/file.spec.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/workers/global/config/parse/file.spec.ts b/lib/workers/global/config/parse/file.spec.ts index 822f67bda24e1a..89f92f183268f1 100644 --- a/lib/workers/global/config/parse/file.spec.ts +++ b/lib/workers/global/config/parse/file.spec.ts @@ -75,7 +75,6 @@ describe('workers/global/config/parse/file', () => { `module.exports = { "platform": "github", "token":"abcdef", - "logFileLevel": "warn", "onboarding": false, "gitAuthor": "Renovate Bot " "onboardingConfig": { From 0723e140c1744477805a015839859f546b2fadd6 Mon Sep 17 00:00:00 2001 From: Rahul Gautam Singh Date: Wed, 15 May 2024 20:47:53 +0545 Subject: [PATCH 3/6] update tests --- lib/config/validation.spec.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/config/validation.spec.ts b/lib/config/validation.spec.ts index 9cdc380ca06332..eb5ab06af3b276 100644 --- a/lib/config/validation.spec.ts +++ b/lib/config/validation.spec.ts @@ -1261,9 +1261,10 @@ describe('config/validation', () => { }); describe('validateConfig() -> globaOnly options', () => { - it('returns invalid option warnings', async () => { + it('returns errors for invalid options', async () => { const config = { logFile: 'something', + logFileLevel: 'DEBUG', }; const { errors } = await configValidation.validateConfig( 'global', @@ -1274,6 +1275,10 @@ describe('config/validation', () => { message: 'Invalid configuration option: logFile', topic: 'Configuration Error', }, + { + message: 'Invalid configuration option: logFileLevel', + topic: 'Configuration Error', + }, ]); }); From ec9a5bf1b252458235d9e2c5f7dbc0b7c3223b8d Mon Sep 17 00:00:00 2001 From: Rahul Gautam Singh Date: Wed, 15 May 2024 22:31:51 +0545 Subject: [PATCH 4/6] fix coverage --- lib/config/validation.ts | 6 ------ 1 file changed, 6 deletions(-) diff --git a/lib/config/validation.ts b/lib/config/validation.ts index 092b629665581e..f7d071bac8f12b 100644 --- a/lib/config/validation.ts +++ b/lib/config/validation.ts @@ -882,12 +882,6 @@ async function validateGlobalConfig( currentPath: string | undefined, config: RenovateConfig, ): Promise { - if (getDeprecationMessage(key)) { - warnings.push({ - topic: 'Deprecation Warning', - message: getDeprecationMessage(key)!, - }); - } if (val !== null) { if (type === 'string') { if (is.string(val)) { From 6746bf053bae3ee8dafefa313179e26620623ffe Mon Sep 17 00:00:00 2001 From: RahulGautamSingh Date: Thu, 16 May 2024 22:53:27 +0545 Subject: [PATCH 5/6] Update lib/workers/global/config/parse/index.spec.ts Co-authored-by: HonkingGoose <34918129+HonkingGoose@users.noreply.github.com> --- lib/workers/global/config/parse/index.spec.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/workers/global/config/parse/index.spec.ts b/lib/workers/global/config/parse/index.spec.ts index f8d7936da73c7a..54321079d6528e 100644 --- a/lib/workers/global/config/parse/index.spec.ts +++ b/lib/workers/global/config/parse/index.spec.ts @@ -173,7 +173,7 @@ describe('workers/global/config/parse/index', () => { expect(parsed).toContainEntries([['dryRun', null]]); }); - it('does not initalize file when env var LOG_FILE is undefined', async () => { + it('only initializes the file when the env var LOG_FILE is properly set', async () => { jest.doMock('../../../../../config.js', () => ({}), { virtual: true, }); From 3b07601e63a28975c7d04720083347db16e6a479 Mon Sep 17 00:00:00 2001 From: Rahul Gautam Singh Date: Thu, 16 May 2024 22:56:08 +0545 Subject: [PATCH 6/6] apply suggestion: istanbul ignore --- lib/config/validation.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/config/validation.ts b/lib/config/validation.ts index f7d071bac8f12b..5f054b863db573 100644 --- a/lib/config/validation.ts +++ b/lib/config/validation.ts @@ -882,6 +882,13 @@ async function validateGlobalConfig( currentPath: string | undefined, config: RenovateConfig, ): Promise { + // istanbul ignore if + if (getDeprecationMessage(key)) { + warnings.push({ + topic: 'Deprecation Warning', + message: getDeprecationMessage(key)!, + }); + } if (val !== null) { if (type === 'string') { if (is.string(val)) {