@@ -15,6 +15,7 @@ import {
1515import { LanguageServerType } from '../activation/types' ;
1616import '../common/extensions' ;
1717import { IInterpreterAutoSeletionProxyService , IInterpreterSecurityService } from '../interpreter/autoSelection/types' ;
18+ import { LogLevel } from '../logging/levels' ;
1819import { sendTelemetryEvent } from '../telemetry' ;
1920import { EventName } from '../telemetry/constants' ;
2021import { 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' ;
4447import { 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+ }
0 commit comments