@@ -450,7 +450,7 @@ export class Remote {
450
450
return
451
451
}
452
452
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
454
454
} )
455
455
456
456
// Register the label formatter again because SSH overrides it!
@@ -476,20 +476,22 @@ export class Remote {
476
476
}
477
477
478
478
/**
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.
480
481
*/
481
- private async formatLogArg ( featureSet : FeatureSet ) : Promise < string > {
482
+ private async getLogDir ( featureSet : FeatureSet ) : string {
482
483
if ( ! featureSet . proxyLogDirectory ) {
483
484
return ""
484
485
}
485
-
486
486
// 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
+ }
492
489
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 > {
493
495
await fs . mkdir ( logDir , { recursive : true } )
494
496
this . storage . writeToCoderOutputChannel ( `SSH proxy diagnostics are being written to ${ logDir } ` )
495
497
return ` --log-dir ${ escape ( logDir ) } `
@@ -581,11 +583,13 @@ export class Remote {
581
583
headerArg = ` --header-command ${ escapeSubcommand ( headerCommand ) } `
582
584
}
583
585
586
+ const logDir = this . getLogDir ( featureSet )
587
+
584
588
const sshValues : SSHValues = {
585
589
Host : label ? `${ AuthorityPrefix } .${ label } --*` : `${ AuthorityPrefix } --*` ,
586
590
ProxyCommand : `${ escape ( binaryPath ) } ${ headerArg } vscodessh --network-info-dir ${ escape (
587
591
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 (
589
593
this . storage . getUrlPath ( label ) ,
590
594
) } %h`,
591
595
ConnectTimeout : "0" ,
0 commit comments