Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(logging)!: drop logFile and logFileLevel #29104

Merged
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions docs/usage/self-hosted-configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
19 changes: 0 additions & 19 deletions lib/config/options/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.',
Expand Down
3 changes: 0 additions & 3 deletions lib/config/types.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -114,8 +113,6 @@ export interface GlobalOnlyConfig {
gitNoVerify?: GitNoVerifyOption[];
gitPrivateKey?: string;
globalExtends?: string[];
logFile?: string;
logFileLevel?: LogLevel;
platform?: PlatformId;
prCommitsPerRunLimit?: number;
privateKeyPath?: string;
Expand Down
16 changes: 10 additions & 6 deletions lib/config/validation.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1261,19 +1261,23 @@ describe('config/validation', () => {
});

describe('validateConfig() -> globaOnly options', () => {
it('returns deprecation warnings', async () => {
it('returns errors for invalid options', async () => {
const config = {
logFile: 'something',
logFileLevel: 'DEBUG',
};
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',
},
{
message: 'Invalid configuration option: logFileLevel',
topic: 'Configuration Error',
},
]);
});
Expand Down
8 changes: 0 additions & 8 deletions lib/config/validation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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];
}
Expand Down Expand Up @@ -884,12 +882,6 @@ async function validateGlobalConfig(
currentPath: string | undefined,
config: RenovateConfig,
): Promise<void> {
if (getDeprecationMessage(key)) {
warnings.push({
topic: 'Deprecation Warning',
message: getDeprecationMessage(key)!,
});
}
if (val !== null) {
if (type === 'string') {
if (is.string(val)) {
Expand Down
1 change: 0 additions & 1 deletion lib/workers/global/config/parse/file.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ describe('workers/global/config/parse/file', () => {
`module.exports = {
"platform": "github",
"token":"abcdef",
"logFileLevel": "warn",
"onboarding": false,
"gitAuthor": "Renovate Bot <[email protected]>"
"onboardingConfig": {
Expand Down
27 changes: 4 additions & 23 deletions lib/workers/global/config/parse/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
23 changes: 2 additions & 21 deletions lib/workers/global/config/parse/index.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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');
Expand Down Expand Up @@ -119,9 +104,5 @@ export async function parseConfigs(
config.onboardingNoDeps = 'enabled';
}

// Remove log file entries
delete config.logFile;
delete config.logFileLevel;

return config;
}