Skip to content

Commit 85703cc

Browse files
committed
Fix the open log command
The command was opening the old log path.
1 parent 70eb79b commit 85703cc

File tree

2 files changed

+15
-11
lines changed

2 files changed

+15
-11
lines changed

src/commands.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ export class Commands {
266266
*/
267267
public async viewLogs(): Promise<void> {
268268
if (!this.workspaceLogPath) {
269-
vscode.window.showInformationMessage("No logs available.", this.workspaceLogPath || "<unset>")
269+
vscode.window.showInformationMessage("No logs available. Make sure to set coder.proxyLogDirectory to get logs.", this.workspaceLogPath || "<unset>")
270270
return
271271
}
272272
const uri = vscode.Uri.file(this.workspaceLogPath)

src/remote.ts

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,7 @@ export class Remote {
450450
return
451451
}
452452
disposables.push(this.showNetworkUpdates(pid))
453-
this.commands.workspaceLogPath = path.join(this.storage.getLogPath(), `${pid}.log`)
453+
this.commands.workspaceLogPath = logDir ? path.join(logDir, `${pid}.log`) : undefined
454454
})
455455

456456
// Register the label formatter again because SSH overrides it!
@@ -476,20 +476,22 @@ export class Remote {
476476
}
477477

478478
/**
479-
* Format's the --log-dir argument for the ProxyCommand
479+
* Return the --log-dir argument value for the ProxyCommand. It may be an
480+
* empty string if the setting is not set or the cli does not support it.
480481
*/
481-
private async formatLogArg(featureSet: FeatureSet): Promise<string> {
482+
private async getLogDir(featureSet: FeatureSet): string {
482483
if (!featureSet.proxyLogDirectory) {
483484
return ""
484485
}
485-
486486
// If the proxyLogDirectory is not set in the extension settings we don't send one.
487-
// Question for Asher: How do VSCode extension settings behave in terms of semver for the extension?
488-
const logDir = expandPath(String(vscode.workspace.getConfiguration().get("coder.proxyLogDirectory") ?? "").trim())
489-
if (!logDir) {
490-
return ""
491-
}
487+
return expandPath(String(vscode.workspace.getConfiguration().get("coder.proxyLogDirectory") ?? "").trim())
488+
}
492489

490+
/**
491+
* Formats the --log-dir argument for the ProxyCommand after making sure it
492+
* has been created.
493+
*/
494+
private async formatLogArg(logDir: String): Promise<string> {
493495
await fs.mkdir(logDir, { recursive: true })
494496
this.storage.writeToCoderOutputChannel(`SSH proxy diagnostics are being written to ${logDir}`)
495497
return ` --log-dir ${escape(logDir)}`
@@ -581,11 +583,13 @@ export class Remote {
581583
headerArg = ` --header-command ${escapeSubcommand(headerCommand)}`
582584
}
583585

586+
const logDir = this.getLogDir(featureSet)
587+
584588
const sshValues: SSHValues = {
585589
Host: label ? `${AuthorityPrefix}.${label}--*` : `${AuthorityPrefix}--*`,
586590
ProxyCommand: `${escape(binaryPath)}${headerArg} vscodessh --network-info-dir ${escape(
587591
this.storage.getNetworkInfoPath(),
588-
)}${await this.formatLogArg(featureSet)} --session-token-file ${escape(this.storage.getSessionTokenPath(label))} --url-file ${escape(
592+
)}${await this.formatLogArg(logDir)} --session-token-file ${escape(this.storage.getSessionTokenPath(label))} --url-file ${escape(
589593
this.storage.getUrlPath(label),
590594
)} %h`,
591595
ConnectTimeout: "0",

0 commit comments

Comments
 (0)