Skip to content

Commit b60a4ac

Browse files
committed
new setting for debug level
1 parent 1ecd934 commit b60a4ac

File tree

4 files changed

+26
-6
lines changed

4 files changed

+26
-6
lines changed

package.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,14 @@
273273
"minimum": -1,
274274
"maximum": 32,
275275
"description": "If the gap between registers is less than this threshold (multiple of 8), combine into a single read from device. -1 means never combine registers and is very slow"
276+
},
277+
"mcu-debug.peripheral-viewer.debugLevel": {
278+
"type": "number",
279+
"default": 0,
280+
"minimum": 0,
281+
"maximum": 2,
282+
"multipleOf": 1,
283+
"description": "Enable debug output in the OUTPUT Tab (Peripheral Viewer section). Some debug output may also be found in the `Mcu-debug Tracker` section which is controlled separately. Changing this value requires a Reload of the window"
276284
}
277285
}
278286
}

src/debug-tracker-wrapper.ts

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,13 @@
66
*/
77

88
import * as vscode from 'vscode';
9+
import * as manifest from './manifest';
910
import { DebugSessionStatus, DebugTracker, IDebuggerTrackerEvent, IDebugTracker, TRACKER_EXT_ID } from 'debug-tracker-vscode';
10-
import { logOutputChannel, logToOutputWindow } from './vscode-utils';
11+
import { setLogOutput, logOutputChannel, logToOutputWindow } from './vscode-utils';
1112

1213
export class DebugTrackerWrapper {
1314
private isLocalTracker = false;
15+
private dbgLevel: 0 | 1 | 2 = 0;
1416
public constructor(private debugType = '*') {
1517
}
1618

@@ -28,6 +30,14 @@ export class DebugTrackerWrapper {
2830

2931
private sessionIdMap: {[id: string]: vscode.DebugSession} = {};
3032
public async activate(context: vscode.ExtensionContext): Promise<void> {
33+
// TODO: Make this dynamic so reloads are needed if setting changes
34+
const dbgLevel = vscode.workspace.getConfiguration(manifest.PACKAGE_NAME).get<number>(manifest.DEBUG_LEVEL, 0);
35+
if ((dbgLevel >= 0) && (dbgLevel <= 2)) {
36+
this.dbgLevel = dbgLevel as 0 | 1 | 2;
37+
}
38+
if (this.dbgLevel > 0) {
39+
setLogOutput(true);
40+
}
3141
logToOutputWindow('activating debug tracker');
3242
const debugtracker = await this.getTracker(context);
3343
if (debugtracker) {
@@ -37,7 +47,7 @@ export class DebugTrackerWrapper {
3747
body: {
3848
debuggers: '*',
3949
handler: async (event: IDebuggerTrackerEvent) => {
40-
if (!this.isLocalTracker) {
50+
if (!this.isLocalTracker || (this.dbgLevel > 1)) {
4151
logToOutputWindow(JSON.stringify(event));
4252
}
4353
const session = this.sessionIdMap[event.sessionId];
@@ -78,7 +88,7 @@ export class DebugTrackerWrapper {
7888
// We could use our own channel in the future for debug
7989
this.isLocalTracker = true;
8090
logToOutputWindow('Using local debug tracker');
81-
ret = new DebugTracker(context, logOutputChannel, 1);
91+
ret = new DebugTracker(context, logOutputChannel, this.dbgLevel);
8292
} else {
8393
logToOutputWindow('Using shared debug tracker');
8494
}

src/manifest.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,4 @@ export const CONFIG_ADDRGAP = 'svdAddrGapThreshold';
1313
export const DEFAULT_ADDRGAP = 16;
1414
export const CONFIG_ASSET_PATH = 'packAssetUrl';
1515
export const DEFAULT_ASSET_PATH = 'https://pack-asset-service.keil.arm.com';
16+
export const DEBUG_LEVEL = 'debugLevel';

src/vscode-utils.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,11 @@ export const getSelection = async (title: string, items: QuickPickItem[], value?
5353
}
5454
};
5555

56-
56+
let enableLogOutput = false;
5757
export let logOutputChannel: vscode.OutputChannel | undefined;
58-
// eslint-disable-next-line prefer-const
59-
export let enableLogOutput = false; // TODO: This should be an extension option
58+
export function setLogOutput(val: boolean) {
59+
enableLogOutput = val;
60+
}
6061
export function logToOutputWindow(msg: string) {
6162
if (enableLogOutput) {
6263
if (!logOutputChannel) {

0 commit comments

Comments
 (0)