From ee73f1ab38fae9a80297bbfb58629c7d9f04e960 Mon Sep 17 00:00:00 2001 From: Kelvin Schoofs Date: Sat, 25 Mar 2023 17:45:23 +0100 Subject: [PATCH] Fix debug launch task, improve logging and fix a VS Code bug regarding logging when debugging --- .vscode/launch.json | 10 ++-------- .vscode/tasks.json | 7 +++++-- src/logging.ts | 4 +++- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index 96229ff..46eb935 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -10,20 +10,14 @@ "args": [ "--extensionDevelopmentPath=${workspaceRoot}" ], - "stopOnEntry": false, "sourceMaps": true, "outFiles": [ - "${workspaceRoot}/out/src/**/*.js" + "${workspaceRoot}/dist/**/*.js", + "${workspaceRoot}/common/out/**/*.js" ], "env": { "VSCODE_SSHFS_DEBUG": "TRUE" }, - "windows": { - "env": { - "VSCODE_SSHFS_DEBUG": "TRUE" - } - } - // "preLaunchTask": "npm:watch" } ] } \ No newline at end of file diff --git a/.vscode/tasks.json b/.vscode/tasks.json index 267b43e..8e563dd 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -5,7 +5,10 @@ "tasks": [ { "label": "Extension - Watch all", - "group": "build", + "group": { + "kind": "build", + "isDefault": true + }, "dependsOrder": "sequence", "dependsOn": [ "Extension Common - Watch", @@ -26,7 +29,7 @@ "Extension WebView - Watch" ], "problemMatcher": [], - "isBackground": true, + "isBackground": true }, { "type": "shell", diff --git a/src/logging.ts b/src/logging.ts index b219c0e..a36ddce 100644 --- a/src/logging.ts +++ b/src/logging.ts @@ -107,6 +107,8 @@ class Logger { const space = ' '.repeat(Math.max(0, 8 - type.length)); const msg = `[${type}]${space}${prefix}${message}${suffix}` outputChannel.appendLine(msg); + // VS Code issue where console.debug logs twice in the Debug Console + if (type.toLowerCase() === 'debug') type = 'log'; if (DEBUG) (console[type.toLowerCase()] || console.log).call(console, msg); } protected formatValue(value: any, options: LoggingOptions): string { @@ -166,7 +168,7 @@ class Logger { protected printTemplate(type: string, template: TemplateStringsArray, args: any[], partialOptions?: Partial) { const options: LoggingOptions = { ...this.defaultLoggingOptions, ...partialOptions }; options.callStacktraceOffset = (options.callStacktraceOffset || 0) + 1; - this.print(type, template.reduce((acc, part, i) => acc + part + this.formatValue(args[i] || '', options), ''), partialOptions); + this.print(type, template.reduce((acc, part, i) => acc + part + (i < args.length ? this.formatValue(args[i], options) : ''), ''), partialOptions); } public scope(name?: string, generateStack: number | boolean = false) { const logger = new Logger(name, generateStack);