From 18f811a62823d0c075f4274825f019ea4d68040e Mon Sep 17 00:00:00 2001 From: Rob Lourens Date: Fri, 20 Aug 2021 19:01:45 -0700 Subject: [PATCH] Log debug adapter traffic Add a "verbose" logging level Fix #6468 --- package.json | 3 ++- src/client/common/configSettings.ts | 3 +++ src/client/common/types.ts | 2 +- src/client/debugger/jupyter/kernelDebugAdapter.ts | 10 +++++++++- src/client/extensionActivation.ts | 6 +++++- src/client/logging/_global.ts | 2 +- 6 files changed, 21 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 6b5e7217a1ee..ca0bed816f12 100644 --- a/package.json +++ b/package.json @@ -1520,7 +1520,8 @@ "error", "warn", "info", - "debug" + "debug", + "verbose" ], "description": "The logging level the extension logs at.", "scope": "machine" diff --git a/src/client/common/configSettings.ts b/src/client/common/configSettings.ts index 93639b298191..a0e9c7251f6d 100644 --- a/src/client/common/configSettings.ts +++ b/src/client/common/configSettings.ts @@ -273,6 +273,9 @@ function convertSettingTypeToLogLevel(setting: LoggingLevelSettingType | undefin case 'debug': { return LogLevel.Debug; } + case 'verbose': { + return LogLevel.Trace; + } default: { return LogLevel.Error; } diff --git a/src/client/common/types.ts b/src/client/common/types.ts index 1fece3b5ffd9..042ea8bf0ad0 100644 --- a/src/client/common/types.ts +++ b/src/client/common/types.ts @@ -186,7 +186,7 @@ export interface IWatchableJupyterSettings extends IJupyterSettings { readonly onDidChange: Event; } -export type LoggingLevelSettingType = 'off' | 'error' | 'warn' | 'info' | 'debug'; +export type LoggingLevelSettingType = 'off' | 'error' | 'warn' | 'info' | 'debug' | 'verbose'; export interface ILoggingSettings { readonly level: LogLevel | 'off'; diff --git a/src/client/debugger/jupyter/kernelDebugAdapter.ts b/src/client/debugger/jupyter/kernelDebugAdapter.ts index 08b9e827b221..7dff9d48198e 100644 --- a/src/client/debugger/jupyter/kernelDebugAdapter.ts +++ b/src/client/debugger/jupyter/kernelDebugAdapter.ts @@ -25,7 +25,7 @@ import * as path from 'path'; import { IJupyterSession } from '../../datascience/types'; import { KernelMessage } from '@jupyterlab/services'; import { ICommandManager } from '../../common/application/types'; -import { traceError } from '../../common/logger'; +import { traceError, traceVerbose } from '../../common/logger'; import { IFileSystem } from '../../common/platform/types'; import { IKernelDebugAdapter } from '../types'; import { IDisposable } from '../../common/types'; @@ -202,6 +202,13 @@ export class KernelDebugAdapter implements DebugAdapter, IKernelDebugAdapter, ID this, this.disposables ); + + this.disposables.push( + this.onDidSendMessage(msg => this.trace('to client', JSON.stringify(msg)))); + } + + private trace(tag: string, msg: string) { + traceVerbose(`[Debug] ${tag}: ${msg}`); } async handleMessage(message: DebugProtocol.ProtocolMessage) { @@ -342,6 +349,7 @@ export class KernelDebugAdapter implements DebugAdapter, IKernelDebugAdapter, ID } }); + this.trace('to kernel', JSON.stringify(message)); if (message.type === 'request') { this.sendMessage.fire(message); const request = debugRequest(message as DebugProtocol.Request, this.jupyterSession.sessionId); diff --git a/src/client/extensionActivation.ts b/src/client/extensionActivation.ts index afa136ae403e..46855ba02ebf 100644 --- a/src/client/extensionActivation.ts +++ b/src/client/extensionActivation.ts @@ -112,7 +112,11 @@ async function activateLegacy( // We should start logging using the log level as soon as possible, so set it as soon as we can access the level. // `IConfigurationService` may depend any of the registered types, so doing it after all registrations are finished. // XXX Move this *after* abExperiments is activated? - setLoggingLevel(configuration.getSettings().logging.level); + const settings = configuration.getSettings(); + setLoggingLevel(settings.logging.level); + settings.onDidChange(() => { + setLoggingLevel(settings.logging.level); + }); // Register datascience types after experiments have loaded. // To ensure we can register types based on experiments. diff --git a/src/client/logging/_global.ts b/src/client/logging/_global.ts index ddcb81b96153..35aaf5e90f62 100644 --- a/src/client/logging/_global.ts +++ b/src/client/logging/_global.ts @@ -80,7 +80,7 @@ export function log(logLevel: LogLevel, ...args: Arguments) { // eslint-disable-next-line @typescript-eslint/no-explicit-any export function logVerbose(...args: any[]) { - log(LogLevel.Info, ...args); + log(LogLevel.Trace, ...args); } // eslint-disable-next-line @typescript-eslint/no-explicit-any