Skip to content

Commit 993fc55

Browse files
authored
Ability to prevent logging python execution info (microsoft#7464)
1 parent d1e4a83 commit 993fc55

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

src/client/common/constants.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,8 @@ export namespace Delays {
8080

8181
export const STANDARD_OUTPUT_CHANNEL = 'STANDARD_OUTPUT_CHANNEL';
8282

83+
export const isCI = process.env.TRAVIS === 'true' || process.env.TF_BUILD !== undefined;
84+
8385
export function isTestExecution(): boolean {
8486
return process.env.VSC_PYTHON_CI_TEST === '1' || isUnitTestExecution();
8587
}

src/client/common/process/logger.ts

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
// Copyright (c) Microsoft Corporation. All rights reserved.
22
// Licensed under the MIT License.
3-
import { inject, injectable, named } from 'inversify';
4-
import { STANDARD_OUTPUT_CHANNEL } from '../constants';
53

4+
'use strict';
5+
6+
import { inject, injectable, named } from 'inversify';
7+
import { workspace } from 'vscode';
8+
import { isCI, isTestExecution, STANDARD_OUTPUT_CHANNEL } from '../constants';
69
import { traceInfo } from '../logger';
710
import { IOutputChannel, IPathUtils } from '../types';
811
import { Logging } from '../utils/localize';
@@ -13,9 +16,18 @@ export class ProcessLogger implements IProcessLogger {
1316
constructor(
1417
@inject(IOutputChannel) @named(STANDARD_OUTPUT_CHANNEL) private readonly outputChannel: IOutputChannel,
1518
@inject(IPathUtils) private readonly pathUtils: IPathUtils
16-
) {}
19+
) { }
1720

1821
public logProcess(file: string, args: string[], options?: SpawnOptions) {
22+
if (
23+
!isTestExecution() &&
24+
isCI &&
25+
!workspace.getConfiguration('python', null).get<boolean>('enableProcessLogging', true)
26+
) {
27+
// Added to disable logging of process execution commands during UI Tests.
28+
// Used only during UI Tests (hence this setting need not be exposed as a valid setting).
29+
return;
30+
}
1931
const argsList = args.reduce((accumulator, current, index) => {
2032
let formattedArg = this.pathUtils.getDisplayName(current).toCommandArgument();
2133
if (current[0] === '\'' || current[0] === '"') {

0 commit comments

Comments
 (0)