diff --git a/src/client/common/process/proc.ts b/src/client/common/process/proc.ts index 0ac610e3eac9..18add7daf6fa 100644 --- a/src/client/common/process/proc.ts +++ b/src/client/common/process/proc.ts @@ -40,13 +40,15 @@ export class ProcessService extends EventEmitter implements IProcessService { } public execObservable(file: string, args: string[], options: SpawnOptions = {}): ObservableExecutionResult { - const result = execObservable(file, args, options, this.env, this.processesToKill); + const execOptions = { ...options, doNotLog: true }; + const result = execObservable(file, args, execOptions, this.env, this.processesToKill); this.emit('exec', file, args, options); return result; } public exec(file: string, args: string[], options: SpawnOptions = {}): Promise> { - const promise = plainExec(file, args, options, this.env, this.processesToKill); + const execOptions = { ...options, doNotLog: true }; + const promise = plainExec(file, args, execOptions, this.env, this.processesToKill); this.emit('exec', file, args, options); return promise; } @@ -54,7 +56,8 @@ export class ProcessService extends EventEmitter implements IProcessService { public shellExec(command: string, options: ShellOptions = {}): Promise> { this.emit('exec', command, undefined, options); const disposables = new Set(); - return shellExec(command, options, this.env, disposables).finally(() => { + const shellOptions = { ...options, doNotLog: true }; + return shellExec(command, shellOptions, this.env, disposables).finally(() => { // Ensure the process we started is cleaned up. disposables.forEach((p) => { try { diff --git a/src/client/common/process/rawProcessApis.ts b/src/client/common/process/rawProcessApis.ts index 7d7a66cae884..1e1b742a031c 100644 --- a/src/client/common/process/rawProcessApis.ts +++ b/src/client/common/process/rawProcessApis.ts @@ -12,6 +12,8 @@ import { ExecutionResult, ObservableExecutionResult, Output, ShellOptions, Spawn import { noop } from '../utils/misc'; import { decodeBuffer } from './decoder'; import { traceVerbose } from '../../logging'; +import { WorkspaceService } from '../application/workspace'; +import { ProcessLogger } from './logger'; const PS_ERROR_SCREEN_BOGUS = /your [0-9]+x[0-9]+ screen size is bogus\. expect trouble/; @@ -49,12 +51,16 @@ function getDefaultOptions(options: T, de export function shellExec( command: string, - options: ShellOptions = {}, + options: ShellOptions & { doNotLog?: boolean } = {}, defaultEnv?: EnvironmentVariables, disposables?: Set, ): Promise> { const shellOptions = getDefaultOptions(options, defaultEnv); traceVerbose(`Shell Exec: ${command} with options: ${JSON.stringify(shellOptions, null, 4)}`); + if (!options.doNotLog) { + const processLogger = new ProcessLogger(new WorkspaceService()); + processLogger.logProcess(command, undefined, shellOptions); + } return new Promise((resolve, reject) => { // eslint-disable-next-line @typescript-eslint/no-explicit-any const callback = (e: any, stdout: any, stderr: any) => { @@ -90,12 +96,16 @@ export function shellExec( export function plainExec( file: string, args: string[], - options: SpawnOptions = {}, + options: SpawnOptions & { doNotLog?: boolean } = {}, defaultEnv?: EnvironmentVariables, disposables?: Set, ): Promise> { const spawnOptions = getDefaultOptions(options, defaultEnv); const encoding = spawnOptions.encoding ? spawnOptions.encoding : 'utf8'; + if (!options.doNotLog) { + const processLogger = new ProcessLogger(new WorkspaceService()); + processLogger.logProcess(file, args, options); + } const proc = spawn(file, args, spawnOptions); // Listen to these errors (unhandled errors in streams tears down the process). // Errors will be bubbled up to the `error` event in `proc`, hence no need to log. @@ -192,12 +202,16 @@ function removeCondaRunMarkers(out: string) { export function execObservable( file: string, args: string[], - options: SpawnOptions = {}, + options: SpawnOptions & { doNotLog?: boolean } = {}, defaultEnv?: EnvironmentVariables, disposables?: Set, ): ObservableExecutionResult { const spawnOptions = getDefaultOptions(options, defaultEnv); const encoding = spawnOptions.encoding ? spawnOptions.encoding : 'utf8'; + if (!options.doNotLog) { + const processLogger = new ProcessLogger(new WorkspaceService()); + processLogger.logProcess(file, args, options); + } const proc = spawn(file, args, spawnOptions); let procExited = false; const disposable: IDisposable = {