Unnamed repository; edit this file 'description' to name the repository.
Merge pull request #19422 from Veykril/push-xlmxtopzlmxm
chore: Cleanup vscode extension output channels
Lukas Wirth 2025-03-24
parent fcbba4e · parent 78f4146 · commit d8792ee
-rw-r--r--docs/book/src/contributing/README.md9
-rw-r--r--editors/code/package.json5
-rw-r--r--editors/code/src/config.ts1
-rw-r--r--editors/code/src/ctx.ts4
-rw-r--r--editors/code/src/debug.ts15
-rw-r--r--editors/code/src/toolchain.ts7
-rw-r--r--editors/code/src/util.ts2
7 files changed, 16 insertions, 27 deletions
diff --git a/docs/book/src/contributing/README.md b/docs/book/src/contributing/README.md
index 9e1cdb0889..05286b5429 100644
--- a/docs/book/src/contributing/README.md
+++ b/docs/book/src/contributing/README.md
@@ -140,9 +140,10 @@ By default, log goes to stderr, but the stderr itself is processed by VS Code.
`--log-file <PATH>` CLI argument allows logging to file.
Setting the `RA_LOG_FILE=<PATH>` environment variable will also log to file, it will also override `--log-file`.
-To see stderr in the running VS Code instance, go to the "Output" tab of the panel and select `Rust Analyzer Client`.
+To see the server stderr output in the running VS Code instance, go to the "Output" tab of the panel
+and select `rust-analyzer Language Server`.
This shows `eprintln!` as well.
-Note that `stdout` is used for the actual protocol, so `println!` will break things.
+Note that `stdout` is used by LSP messages, so using `println!`—or anything that writes to `stdout`—will break rust-analyzer!
To log all communication between the server and the client, there are two choices:
@@ -153,9 +154,11 @@ To log all communication between the server and the client, there are two choice
```
* You can log on the client side, by the `rust-analyzer: Toggle LSP Logs` command or enabling `"rust-analyzer.trace.server": "verbose"` workspace setting.
- These logs are shown in a separate tab in the output and could be used with LSP inspector.
+ These logs are shown in a separate tab named `rust-analyzer LSP Trace` in the output and could be used with LSP inspector.
Kudos to [@DJMcNab](https://github.com/DJMcNab) for setting this awesome infra up!
+Finally there are the logs of the VSCode extension itself which go into the `rust-analyzer Extension` output tab.
+
There are also several VS Code commands which might be of interest:
* `rust-analyzer: Status` shows some memory-usage statistics.
diff --git a/editors/code/package.json b/editors/code/package.json
index 11732ddd3e..55477b7115 100644
--- a/editors/code/package.json
+++ b/editors/code/package.json
@@ -606,11 +606,6 @@
"/rustc/<id>": "${env:USERPROFILE}/.rustup/toolchains/<toolchain-id>/lib/rustlib/src/rust"
}
},
- "rust-analyzer.debug.openDebugPane": {
- "markdownDescription": "Whether to open up the `Debug Panel` on debugging start.",
- "type": "boolean",
- "default": false
- },
"rust-analyzer.debug.buildBeforeRestart": {
"markdownDescription": "Whether to rebuild the project modules before debugging the same test again",
"type": "boolean",
diff --git a/editors/code/src/config.ts b/editors/code/src/config.ts
index 896b3c10cb..9b8ac666ce 100644
--- a/editors/code/src/config.ts
+++ b/editors/code/src/config.ts
@@ -323,7 +323,6 @@ export class Config {
return {
engine: this.get<string>("debug.engine"),
engineSettings: this.get<object>("debug.engineSettings") ?? {},
- openDebugPane: this.get<boolean>("debug.openDebugPane"),
buildBeforeRestart: this.get<boolean>("debug.buildBeforeRestart"),
sourceFileMap: sourceFileMap,
};
diff --git a/editors/code/src/ctx.ts b/editors/code/src/ctx.ts
index 37a2ee2369..1149523622 100644
--- a/editors/code/src/ctx.ts
+++ b/editors/code/src/ctx.ts
@@ -190,11 +190,11 @@ export class Ctx implements RustAnalyzerExtensionApi {
}
if (!this.traceOutputChannel) {
- this.traceOutputChannel = new LazyOutputChannel("Rust Analyzer Language Server Trace");
+ this.traceOutputChannel = new LazyOutputChannel("rust-analyzer LSP Trace");
this.pushExtCleanup(this.traceOutputChannel);
}
if (!this.outputChannel) {
- this.outputChannel = vscode.window.createOutputChannel("Rust Analyzer Language Server");
+ this.outputChannel = vscode.window.createOutputChannel("rust-analyzer Language Server");
this.pushExtCleanup(this.outputChannel);
}
diff --git a/editors/code/src/debug.ts b/editors/code/src/debug.ts
index 72a9aabc04..04211d77e7 100644
--- a/editors/code/src/debug.ts
+++ b/editors/code/src/debug.ts
@@ -6,11 +6,9 @@ import type * as ra from "./lsp_ext";
import { Cargo } from "./toolchain";
import type { Ctx } from "./ctx";
import { createTaskFromRunnable, prepareEnv } from "./run";
-import { execute, isCargoRunnableArgs, unwrapUndefinable } from "./util";
+import { execute, isCargoRunnableArgs, unwrapUndefinable, log } from "./util";
import type { Config } from "./config";
-const debugOutput = vscode.window.createOutputChannel("Debug");
-
// Here we want to keep track on everything that's currently running
const activeDebugSessionIds: string[] = [];
@@ -56,15 +54,14 @@ export async function startDebugSession(ctx: Ctx, runnable: ra.Runnable): Promis
if (-1 !== index) {
debugConfig = configurations[index];
message = " (from launch.json)";
- debugOutput.clear();
} else {
debugConfig = await getDebugConfiguration(ctx.config, runnable);
}
if (!debugConfig) return false;
- debugOutput.appendLine(`Launching debug configuration${message}:`);
- debugOutput.appendLine(JSON.stringify(debugConfig, null, 2));
+ log.debug(`Launching debug configuration${message}:`);
+ log.debug(JSON.stringify(debugConfig, null, 2));
return vscode.debug.startDebugging(undefined, debugConfig);
}
@@ -118,10 +115,6 @@ async function getDebugConfiguration(
return;
}
- debugOutput.clear();
- if (config.debug.openDebugPane) {
- debugOutput.show(true);
- }
// folder exists or RA is not active.
const workspaceFolders = vscode.workspace.workspaceFolders!;
@@ -321,7 +314,7 @@ async function getDebugExecutable(
runnableArgs: ra.CargoRunnableArgs,
env: Record<string, string>,
): Promise<string> {
- const cargo = new Cargo(runnableArgs.workspaceRoot || ".", debugOutput, env);
+ const cargo = new Cargo(runnableArgs.workspaceRoot || ".", env);
const executable = await cargo.executableFromArgs(runnableArgs);
// if we are here, there were no compilation errors.
diff --git a/editors/code/src/toolchain.ts b/editors/code/src/toolchain.ts
index bb06144295..a859ce6ff0 100644
--- a/editors/code/src/toolchain.ts
+++ b/editors/code/src/toolchain.ts
@@ -37,7 +37,6 @@ interface CompilerMessage {
export class Cargo {
constructor(
readonly rootFolder: string,
- readonly output: vscode.OutputChannel,
readonly env: Record<string, string>,
) {}
@@ -93,14 +92,14 @@ export class Cargo {
});
}
} else if (message.reason === "compiler-message") {
- this.output.append(message.message.rendered);
+ log.info(message.message.rendered);
}
},
- (stderr) => this.output.append(stderr),
+ (stderr) => log.error(stderr),
env,
);
} catch (err) {
- this.output.show(true);
+ log.error(`Cargo invocation has failed: ${err}`);
throw new Error(`Cargo invocation has failed: ${err}`);
}
diff --git a/editors/code/src/util.ts b/editors/code/src/util.ts
index 93c7bf8d73..4b3a6970db 100644
--- a/editors/code/src/util.ts
+++ b/editors/code/src/util.ts
@@ -18,7 +18,7 @@ export type Env = {
};
class Log {
- private readonly output = vscode.window.createOutputChannel("Rust Analyzer Client", {
+ private readonly output = vscode.window.createOutputChannel("rust-analyzer Extension", {
log: true,
});