@@ -541,6 +541,26 @@ export class Remote {
541
541
}
542
542
}
543
543
544
+ /**
545
+ * Format's the --log-dir argument for the ProxyCommand
546
+ */
547
+ private async formatLogArg ( ) : Promise < string > {
548
+ if ( ! supportsCoderAgentLogDirFlag ( this . coderVersion ) ) {
549
+ return ""
550
+ }
551
+
552
+ // If the proxyLogDirectory is not set in the extension settings we don't send one.
553
+ // Question for Asher: How do VSCode extension settings behave in terms of semver for the extension?
554
+ const logDir = expandPath ( String ( vscode . workspace . getConfiguration ( ) . get ( "coder.proxyLogDirectory" ) ?? "" ) . trim ( ) )
555
+ if ( ! logDir ) {
556
+ return ""
557
+ }
558
+
559
+ await fs . mkdir ( logDir , { recursive : true } )
560
+ this . storage . writeToCoderOutputChannel ( `Your logs are being written to ${ logDir } ` )
561
+ return ` --log-dir ${ escape ( logDir ) } `
562
+ }
563
+
544
564
// updateSSHConfig updates the SSH configuration with a wildcard that handles
545
565
// all Coder entries.
546
566
private async updateSSHConfig ( restClient : Api , label : string , hostName : string ) {
@@ -634,20 +654,12 @@ export class Remote {
634
654
if ( typeof headerCommand === "string" && headerCommand . trim ( ) . length > 0 ) {
635
655
headerArg = ` --header-command ${ escapeSubcommand ( headerCommand ) } `
636
656
}
637
- let logArg = ""
638
- if ( supportsCoderAgentLogDirFlag ( this . coderVersion ) ) {
639
- const logDir = expandPath ( String ( vscode . workspace . getConfiguration ( ) . get ( "coder.proxyLogDirectory" ) ?? "" ) . trim ( ) )
640
- if ( logDir ) {
641
- await fs . mkdir ( logDir , { recursive : true } )
642
- logArg = ` --log-dir ${ escape ( logDir ) } `
643
- this . storage . writeToCoderOutputChannel ( `Your logs are being written to ${ logDir } ` )
644
- }
645
- }
657
+
646
658
const sshValues : SSHValues = {
647
659
Host : label ? `${ AuthorityPrefix } .${ label } --*` : `${ AuthorityPrefix } --*` ,
648
660
ProxyCommand : `${ escape ( binaryPath ) } ${ headerArg } vscodessh --network-info-dir ${ escape (
649
661
this . storage . getNetworkInfoPath ( ) ,
650
- ) } ${ logArg } --session-token-file ${ escape ( this . storage . getSessionTokenPath ( label ) ) } --url-file ${ escape (
662
+ ) } ${ await this . formatLogArg ( ) } --session-token-file ${ escape ( this . storage . getSessionTokenPath ( label ) ) } --url-file ${ escape (
651
663
this . storage . getUrlPath ( label ) ,
652
664
) } %h`,
653
665
ConnectTimeout : "0" ,
0 commit comments