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": [
"--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"
}
]
}

@ -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",

@ -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<LoggingOptions>) {
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);

Loading…
Cancel
Save