Skip to content

Commit

Permalink
Remove all uses of static methods of Logger class (#9827)
Browse files Browse the repository at this point in the history
* Remove all direct uses of static methods of Logger class

* Remove uses from within the class itself
Kartik Raj authored Jan 30, 2020

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent 92ee74e commit 89ef1aa
Showing 6 changed files with 15 additions and 15 deletions.
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@
import { inject, injectable } from 'inversify';
import { DiagnosticSeverity } from 'vscode';
import '../../../common/extensions';
import { Logger } from '../../../common/logger';
import { traceError } from '../../../common/logger';
import { useCommandPromptAsDefaultShell } from '../../../common/terminal/commandPrompt';
import { IConfigurationService, ICurrentProcess, IDisposableRegistry, Resource } from '../../../common/types';
import { IServiceContainer } from '../../../ioc/types';
@@ -68,7 +68,7 @@ export class PowerShellActivationHackDiagnosticsService extends BaseDiagnosticsS
sendTelemetryEvent(EventName.DIAGNOSTICS_ACTION, undefined, {
action: 'switchToCommandPrompt'
});
useCommandPromptAsDefaultShell(currentProcess, configurationService).catch(ex => Logger.error('Use Command Prompt as default shell', ex));
useCommandPromptAsDefaultShell(currentProcess, configurationService).catch(ex => traceError('Use Command Prompt as default shell', ex));
}
}
},
6 changes: 3 additions & 3 deletions src/client/common/logger.ts
Original file line number Diff line number Diff line change
@@ -206,13 +206,13 @@ export class Logger implements ILogger {
}
}
public logError(...args: any[]) {
Logger.error(...args);
traceError(...args);
}
public logWarning(...args: any[]) {
Logger.warn(...args);
traceWarning(...args);
}
public logInformation(...args: any[]) {
Logger.verbose(...args);
traceVerbose(...args);
}
}

Original file line number Diff line number Diff line change
@@ -8,7 +8,7 @@ import * as md5 from 'md5';
import { Disposable, Event, EventEmitter, Uri } from 'vscode';
import { IWorkspaceService } from '../../../common/application/types';
import '../../../common/extensions';
import { Logger, traceDecorators, traceVerbose } from '../../../common/logger';
import { traceDecorators, traceVerbose } from '../../../common/logger';
import { IDisposableRegistry, IPersistentStateFactory } from '../../../common/types';
import { createDeferred, Deferred } from '../../../common/utils/async';
import { StopWatch } from '../../../common/utils/stopWatch';
@@ -88,7 +88,7 @@ export abstract class CacheableLocatorService implements IInterpreterLocatorServ
watchers.forEach(watcher => {
watcher.onDidCreate(
() => {
Logger.verbose(`Interpreter Watcher change handler for ${this.cacheKeyPrefix}`);
traceVerbose(`Interpreter Watcher change handler for ${this.cacheKeyPrefix}`);
this.promisesPerResource.delete(cacheKey);
this.getInterpreters(resource).ignoreErrors();
},
6 changes: 3 additions & 3 deletions src/client/interpreter/locators/services/condaService.ts
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@ import { compare, parse, SemVer } from 'semver';
import { ConfigurationChangeEvent, Uri } from 'vscode';

import { IWorkspaceService } from '../../../common/application/types';
import { Logger, traceDecorators, traceVerbose } from '../../../common/logger';
import { traceDecorators, traceVerbose, traceWarning } from '../../../common/logger';
import { IFileSystem, IPlatformService } from '../../../common/platform/types';
import { IProcessServiceFactory } from '../../../common/process/types';
import { IConfigurationService, IDisposableRegistry, ILogger, IPersistentStateFactory } from '../../../common/types';
@@ -128,7 +128,7 @@ export class CondaService implements ICondaService {
return version;
}
// Use a bogus version, at least to indicate the fact that a version was returned.
Logger.warn(`Unable to parse Version of Conda, ${versionString}`);
traceWarning(`Unable to parse Version of Conda, ${versionString}`);
return new SemVer('0.0.1');
}

@@ -376,7 +376,7 @@ export class CondaService implements ICondaService {
private async getCondaFileFromKnownLocations(): Promise<string> {
const globPattern = this.platform.isWindows ? CondaLocationsGlobWin : CondaLocationsGlob;
const condaFiles = await this.fileSystem.search(globPattern).catch<string[]>(failReason => {
Logger.warn('Default conda location search failed.', `Searching for default install locations for conda results in error: ${failReason}`);
traceWarning('Default conda location search failed.', `Searching for default install locations for conda results in error: ${failReason}`);
return [];
});
const validCondaFiles = condaFiles.filter(condaPath => condaPath.length > 0);
Original file line number Diff line number Diff line change
@@ -8,7 +8,7 @@ import * as path from 'path';
import { Disposable, Event, EventEmitter, FileSystemWatcher, RelativePattern, Uri } from 'vscode';
import { IWorkspaceService } from '../../../common/application/types';
import '../../../common/extensions';
import { Logger, traceDecorators } from '../../../common/logger';
import { traceDecorators, traceVerbose } from '../../../common/logger';
import { IPlatformService } from '../../../common/platform/types';
import { IPythonExecutionFactory } from '../../../common/process/types';
import { IDisposableRegistry, Resource } from '../../../common/types';
@@ -50,7 +50,7 @@ export class WorkspaceVirtualEnvWatcherService implements IInterpreterWatcher, D

for (const pattern of patterns) {
const globPatern = workspaceFolder ? new RelativePattern(workspaceFolder.uri.fsPath, pattern) : pattern;
Logger.verbose(`Create file systemwatcher with pattern ${pattern}`);
traceVerbose(`Create file systemwatcher with pattern ${pattern}`);

const fsWatcher = this.workspaceService.createFileSystemWatcher(globPatern);
fsWatcher.onDidCreate(e => this.createHandler(e), this, this.disposableRegistry);
6 changes: 3 additions & 3 deletions src/client/providers/jediProxy.ts
Original file line number Diff line number Diff line change
@@ -21,7 +21,7 @@ import { PythonInterpreter } from '../interpreter/contracts';
import { IServiceContainer } from '../ioc/types';
import { sendTelemetryEvent } from '../telemetry';
import { EventName } from '../telemetry/constants';
import { Logger, traceError } from './../common/logger';
import { traceError } from './../common/logger';

const pythonVSCodeTypeMappings = new Map<string, CompletionItemKind>();
pythonVSCodeTypeMappings.set('none', CompletionItemKind.Value);
@@ -348,7 +348,7 @@ export class JediProxy implements Disposable {
}

private handleError(source: string, errorMessage: string) {
Logger.error(`${source} jediProxy`, `Error (${source}) ${errorMessage}`);
traceError(`${source} jediProxy`, `Error (${source}) ${errorMessage}`);
}

// tslint:disable-next-line:max-func-body-length
@@ -373,7 +373,7 @@ export class JediProxy implements Disposable {
this.proc = result.proc;
this.languageServerStarted.resolve();
this.proc!.on('end', end => {
Logger.error('spawnProcess.end', `End - ${end}`);
traceError('spawnProcess.end', `End - ${end}`);
});
this.proc!.on('error', error => {
this.handleError('error', `${error}`);

0 comments on commit 89ef1aa

Please sign in to comment.