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