Fix debug launch task, improve logging and fix a VS Code bug regarding logging when debugging

pull/373/head
Kelvin Schoofs 2 years ago
parent 4a6203508a
commit ee73f1ab38

@ -10,20 +10,14 @@
"args": [ "args": [
"--extensionDevelopmentPath=${workspaceRoot}" "--extensionDevelopmentPath=${workspaceRoot}"
], ],
"stopOnEntry": false,
"sourceMaps": true, "sourceMaps": true,
"outFiles": [ "outFiles": [
"${workspaceRoot}/out/src/**/*.js" "${workspaceRoot}/dist/**/*.js",
"${workspaceRoot}/common/out/**/*.js"
], ],
"env": { "env": {
"VSCODE_SSHFS_DEBUG": "TRUE" "VSCODE_SSHFS_DEBUG": "TRUE"
}, },
"windows": {
"env": {
"VSCODE_SSHFS_DEBUG": "TRUE"
}
}
// "preLaunchTask": "npm:watch"
} }
] ]
} }

@ -5,7 +5,10 @@
"tasks": [ "tasks": [
{ {
"label": "Extension - Watch all", "label": "Extension - Watch all",
"group": "build", "group": {
"kind": "build",
"isDefault": true
},
"dependsOrder": "sequence", "dependsOrder": "sequence",
"dependsOn": [ "dependsOn": [
"Extension Common - Watch", "Extension Common - Watch",
@ -26,7 +29,7 @@
"Extension WebView - Watch" "Extension WebView - Watch"
], ],
"problemMatcher": [], "problemMatcher": [],
"isBackground": true, "isBackground": true
}, },
{ {
"type": "shell", "type": "shell",

@ -107,6 +107,8 @@ class Logger {
const space = ' '.repeat(Math.max(0, 8 - type.length)); const space = ' '.repeat(Math.max(0, 8 - type.length));
const msg = `[${type}]${space}${prefix}${message}${suffix}` const msg = `[${type}]${space}${prefix}${message}${suffix}`
outputChannel.appendLine(msg); 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); if (DEBUG) (console[type.toLowerCase()] || console.log).call(console, msg);
} }
protected formatValue(value: any, options: LoggingOptions): string { protected formatValue(value: any, options: LoggingOptions): string {
@ -166,7 +168,7 @@ class Logger {
protected printTemplate(type: string, template: TemplateStringsArray, args: any[], partialOptions?: Partial<LoggingOptions>) { protected printTemplate(type: string, template: TemplateStringsArray, args: any[], partialOptions?: Partial<LoggingOptions>) {
const options: LoggingOptions = { ...this.defaultLoggingOptions, ...partialOptions }; const options: LoggingOptions = { ...this.defaultLoggingOptions, ...partialOptions };
options.callStacktraceOffset = (options.callStacktraceOffset || 0) + 1; 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) { public scope(name?: string, generateStack: number | boolean = false) {
const logger = new Logger(name, generateStack); const logger = new Logger(name, generateStack);

Loading…
Cancel
Save