mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-28 02:29:44 +00:00
chore: Cleanup vscode extension output channels
This commit is contained in:
parent
3bf18d4eba
commit
78f4146dc7
7 changed files with 16 additions and 27 deletions
|
|
@ -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.
|
`--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`.
|
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.
|
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:
|
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.
|
* 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!
|
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:
|
There are also several VS Code commands which might be of interest:
|
||||||
|
|
||||||
* `rust-analyzer: Status` shows some memory-usage statistics.
|
* `rust-analyzer: Status` shows some memory-usage statistics.
|
||||||
|
|
|
||||||
|
|
@ -606,11 +606,6 @@
|
||||||
"/rustc/<id>": "${env:USERPROFILE}/.rustup/toolchains/<toolchain-id>/lib/rustlib/src/rust"
|
"/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": {
|
"rust-analyzer.debug.buildBeforeRestart": {
|
||||||
"markdownDescription": "Whether to rebuild the project modules before debugging the same test again",
|
"markdownDescription": "Whether to rebuild the project modules before debugging the same test again",
|
||||||
"type": "boolean",
|
"type": "boolean",
|
||||||
|
|
|
||||||
|
|
@ -323,7 +323,6 @@ export class Config {
|
||||||
return {
|
return {
|
||||||
engine: this.get<string>("debug.engine"),
|
engine: this.get<string>("debug.engine"),
|
||||||
engineSettings: this.get<object>("debug.engineSettings") ?? {},
|
engineSettings: this.get<object>("debug.engineSettings") ?? {},
|
||||||
openDebugPane: this.get<boolean>("debug.openDebugPane"),
|
|
||||||
buildBeforeRestart: this.get<boolean>("debug.buildBeforeRestart"),
|
buildBeforeRestart: this.get<boolean>("debug.buildBeforeRestart"),
|
||||||
sourceFileMap: sourceFileMap,
|
sourceFileMap: sourceFileMap,
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -190,11 +190,11 @@ export class Ctx implements RustAnalyzerExtensionApi {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!this.traceOutputChannel) {
|
if (!this.traceOutputChannel) {
|
||||||
this.traceOutputChannel = new LazyOutputChannel("Rust Analyzer Language Server Trace");
|
this.traceOutputChannel = new LazyOutputChannel("rust-analyzer LSP Trace");
|
||||||
this.pushExtCleanup(this.traceOutputChannel);
|
this.pushExtCleanup(this.traceOutputChannel);
|
||||||
}
|
}
|
||||||
if (!this.outputChannel) {
|
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);
|
this.pushExtCleanup(this.outputChannel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,11 +6,9 @@ import type * as ra from "./lsp_ext";
|
||||||
import { Cargo } from "./toolchain";
|
import { Cargo } from "./toolchain";
|
||||||
import type { Ctx } from "./ctx";
|
import type { Ctx } from "./ctx";
|
||||||
import { createTaskFromRunnable, prepareEnv } from "./run";
|
import { createTaskFromRunnable, prepareEnv } from "./run";
|
||||||
import { execute, isCargoRunnableArgs, unwrapUndefinable } from "./util";
|
import { execute, isCargoRunnableArgs, unwrapUndefinable, log } from "./util";
|
||||||
import type { Config } from "./config";
|
import type { Config } from "./config";
|
||||||
|
|
||||||
const debugOutput = vscode.window.createOutputChannel("Debug");
|
|
||||||
|
|
||||||
// Here we want to keep track on everything that's currently running
|
// Here we want to keep track on everything that's currently running
|
||||||
const activeDebugSessionIds: string[] = [];
|
const activeDebugSessionIds: string[] = [];
|
||||||
|
|
||||||
|
|
@ -56,15 +54,14 @@ export async function startDebugSession(ctx: Ctx, runnable: ra.Runnable): Promis
|
||||||
if (-1 !== index) {
|
if (-1 !== index) {
|
||||||
debugConfig = configurations[index];
|
debugConfig = configurations[index];
|
||||||
message = " (from launch.json)";
|
message = " (from launch.json)";
|
||||||
debugOutput.clear();
|
|
||||||
} else {
|
} else {
|
||||||
debugConfig = await getDebugConfiguration(ctx.config, runnable);
|
debugConfig = await getDebugConfiguration(ctx.config, runnable);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!debugConfig) return false;
|
if (!debugConfig) return false;
|
||||||
|
|
||||||
debugOutput.appendLine(`Launching debug configuration${message}:`);
|
log.debug(`Launching debug configuration${message}:`);
|
||||||
debugOutput.appendLine(JSON.stringify(debugConfig, null, 2));
|
log.debug(JSON.stringify(debugConfig, null, 2));
|
||||||
return vscode.debug.startDebugging(undefined, debugConfig);
|
return vscode.debug.startDebugging(undefined, debugConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -118,10 +115,6 @@ async function getDebugConfiguration(
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
debugOutput.clear();
|
|
||||||
if (config.debug.openDebugPane) {
|
|
||||||
debugOutput.show(true);
|
|
||||||
}
|
|
||||||
// folder exists or RA is not active.
|
// folder exists or RA is not active.
|
||||||
|
|
||||||
const workspaceFolders = vscode.workspace.workspaceFolders!;
|
const workspaceFolders = vscode.workspace.workspaceFolders!;
|
||||||
|
|
@ -321,7 +314,7 @@ async function getDebugExecutable(
|
||||||
runnableArgs: ra.CargoRunnableArgs,
|
runnableArgs: ra.CargoRunnableArgs,
|
||||||
env: Record<string, string>,
|
env: Record<string, string>,
|
||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
const cargo = new Cargo(runnableArgs.workspaceRoot || ".", debugOutput, env);
|
const cargo = new Cargo(runnableArgs.workspaceRoot || ".", env);
|
||||||
const executable = await cargo.executableFromArgs(runnableArgs);
|
const executable = await cargo.executableFromArgs(runnableArgs);
|
||||||
|
|
||||||
// if we are here, there were no compilation errors.
|
// if we are here, there were no compilation errors.
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,6 @@ interface CompilerMessage {
|
||||||
export class Cargo {
|
export class Cargo {
|
||||||
constructor(
|
constructor(
|
||||||
readonly rootFolder: string,
|
readonly rootFolder: string,
|
||||||
readonly output: vscode.OutputChannel,
|
|
||||||
readonly env: Record<string, string>,
|
readonly env: Record<string, string>,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
|
|
@ -93,14 +92,14 @@ export class Cargo {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
} else if (message.reason === "compiler-message") {
|
} 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,
|
env,
|
||||||
);
|
);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
this.output.show(true);
|
log.error(`Cargo invocation has failed: ${err}`);
|
||||||
throw new Error(`Cargo invocation has failed: ${err}`);
|
throw new Error(`Cargo invocation has failed: ${err}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ export type Env = {
|
||||||
};
|
};
|
||||||
|
|
||||||
class Log {
|
class Log {
|
||||||
private readonly output = vscode.window.createOutputChannel("Rust Analyzer Client", {
|
private readonly output = vscode.window.createOutputChannel("rust-analyzer Extension", {
|
||||||
log: true,
|
log: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue