Skip to content

Commit 17e317b

Browse files
authored
Merge pull request #12432 from ericsnowcurrently/logging-changes-only
Pull in the logging-related changes from the "logging-changes-and-drop-old-debugger" branch.
2 parents da85a76 + fe1a91a commit 17e317b

47 files changed

Lines changed: 816 additions & 379 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

build/ci/templates/test_phases.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -517,12 +517,15 @@ steps:
517517
npm install -g vsce
518518
npm run clean
519519
npx tsc -p ./
520+
mkdir -p ./tmp/client/logging
521+
cp -r ./out/client/logging ./tmp/client
520522
npx gulp clean:cleanExceptTests
521-
mkdir -p ./tmp
522523
cp -r ./out/test ./tmp/test
523524
npm run updateBuildNumber -- --buildNumber $BUILD_BUILDID
524525
npm run package
525526
npx gulp clean:cleanExceptTests
527+
mkdir -p ./out/client/logging
528+
cp -r ./tmp/client/logging ./out/client
526529
cp -r ./tmp/test ./out/test
527530
node --no-force-async-hooks-checks ./out/test/smokeTest.js
528531
displayName: 'Run Smoke Tests'

news/3 Code Health/11699.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Added setting `python.logging.level` which carries the logging level value the extension will log at.

news/3 Code Health/11896.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Monkeypatch `console.*` calls to the logger only in CI.

news/3 Code Health/9837.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Move all logging to the Python output channel.

package.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1712,6 +1712,19 @@
17121712
"description": "Automatically update the language server.",
17131713
"scope": "application"
17141714
},
1715+
"python.logging.level": {
1716+
"type": "string",
1717+
"default": "error",
1718+
"enum": [
1719+
"off",
1720+
"error",
1721+
"warn",
1722+
"info",
1723+
"debug"
1724+
],
1725+
"description": "The logging level the extension logs at, defaults to 'error'",
1726+
"scope": "machine"
1727+
},
17151728
"python.experiments.enabled": {
17161729
"type": "boolean",
17171730
"default": true,

src/client/activation/common/downloader.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ import * as path from 'path';
88
import { ProgressLocation, window } from 'vscode';
99
import { IApplicationShell, IWorkspaceService } from '../../common/application/types';
1010
import '../../common/extensions';
11+
import { traceError } from '../../common/logger';
1112
import { IFileSystem } from '../../common/platform/types';
1213
import { IFileDownloader, IOutputChannel, Resource } from '../../common/types';
1314
import { createDeferred } from '../../common/utils/async';
1415
import { Common, LanguageService } from '../../common/utils/localize';
1516
import { StopWatch } from '../../common/utils/stopWatch';
1617
import { IServiceContainer } from '../../ioc/types';
17-
import { traceError } from '../../logging';
1818
import { sendTelemetryEvent } from '../../telemetry';
1919
import { EventName } from '../../telemetry/constants';
2020
import {

src/client/common/application/customEditorService.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ import * as path from 'path';
66
import * as vscode from 'vscode';
77
import { DataScience } from '../../common/utils/localize';
88

9-
import { traceError } from '../../logging';
109
import { EXTENSION_ROOT_DIR, UseCustomEditorApi } from '../constants';
10+
import { traceError } from '../logger';
1111
import { IFileSystem } from '../platform/types';
1212
import { noop } from '../utils/misc';
1313
import { CustomEditorProvider, IApplicationEnvironment, ICommandManager, ICustomEditorService } from './types';

src/client/common/configSettings.ts

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import {
1515
import { LanguageServerType } from '../activation/types';
1616
import '../common/extensions';
1717
import { IInterpreterAutoSeletionProxyService, IInterpreterSecurityService } from '../interpreter/autoSelection/types';
18+
import { LogLevel } from '../logging/levels';
1819
import { sendTelemetryEvent } from '../telemetry';
1920
import { EventName } from '../telemetry/constants';
2021
import { sendSettingTelemetry } from '../telemetry/envFileTelemetry';
@@ -34,11 +35,13 @@ import {
3435
IFormattingSettings,
3536
IInterpreterPathService,
3637
ILintingSettings,
38+
ILoggingSettings,
3739
IPythonSettings,
3840
ISortImportSettings,
3941
ITerminalSettings,
4042
ITestingSettings,
4143
IWorkspaceSymbolSettings,
44+
LoggingLevelSettingType,
4245
Resource
4346
} from './types';
4447
import { debounceSync } from './utils/decorators';
@@ -111,6 +114,7 @@ export class PythonSettings implements IPythonSettings {
111114
public insidersChannel!: ExtensionChannels;
112115
public experiments!: IExperiments;
113116
public languageServer: LanguageServerType = LanguageServerType.Microsoft;
117+
public logging: ILoggingSettings = { level: LogLevel.Error };
114118

115119
protected readonly changed = new EventEmitter<void>();
116120
private workspaceRoot: Resource;
@@ -251,6 +255,15 @@ export class PythonSettings implements IPythonSettings {
251255
this.devOptions = systemVariables.resolveAny(pythonSettings.get<any[]>('devOptions'))!;
252256
this.devOptions = Array.isArray(this.devOptions) ? this.devOptions : [];
253257

258+
// tslint:disable-next-line: no-any
259+
const loggingSettings = systemVariables.resolveAny(pythonSettings.get<any>('logging'))!;
260+
loggingSettings.level = convertSettingTypeToLogLevel(loggingSettings.level);
261+
if (this.logging) {
262+
Object.assign<ILoggingSettings, ILoggingSettings>(this.logging, loggingSettings);
263+
} else {
264+
this.logging = loggingSettings;
265+
}
266+
254267
// tslint:disable-next-line:no-backbone-get-set-outside-model no-non-null-assertion
255268
const lintingSettings = systemVariables.resolveAny(pythonSettings.get<ILintingSettings>('linting'))!;
256269
if (this.linting) {
@@ -703,3 +716,23 @@ function isValidPythonPath(pythonPath: string): boolean {
703716
return false;
704717
}
705718
}
719+
720+
function convertSettingTypeToLogLevel(setting: LoggingLevelSettingType | undefined): LogLevel | 'off' {
721+
switch (setting) {
722+
case 'info': {
723+
return LogLevel.Info;
724+
}
725+
case 'warn': {
726+
return LogLevel.Warn;
727+
}
728+
case 'off': {
729+
return 'off';
730+
}
731+
case 'debug': {
732+
return LogLevel.Debug;
733+
}
734+
default: {
735+
return LogLevel.Error;
736+
}
737+
}
738+
}

src/client/common/editor.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import { EOL } from 'os';
55
import * as path from 'path';
66
import { Position, Range, TextDocument, TextEdit, Uri, WorkspaceEdit } from 'vscode';
77
import { IFileSystem } from '../common/platform/types';
8-
import { traceError } from '../logging';
98
import { WrappedError } from './errors/errorUtils';
9+
import { traceError } from './logger';
1010
import { IEditorUtils } from './types';
1111
import { isNotebookCell } from './utils/misc';
1212

src/client/common/logger.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1+
// These are all just temporary aliases, for backward compatibility
2+
// and to avoid churn.
13
export {
2-
// aliases:
3-
// (temporarily for backward compatibility and to avoid churn)
44
traceDecorators,
5-
traceError,
6-
traceInfo,
7-
traceVerbose,
8-
traceWarning
9-
} from '../logging/_trace';
10-
export { TraceOptions as LogOptions } from '../logging/types';
5+
logError as traceError,
6+
logInfo as traceInfo,
7+
logVerbose as traceVerbose,
8+
logWarning as traceWarning
9+
} from '../logging';
10+
export { TraceOptions as LogOptions } from '../logging/trace';

0 commit comments

Comments
 (0)