Merge pull request #4511 from cli/jg/keepalive-fix
codespace ssh: fix for nil logger on non-debugging scenarios
This commit is contained in:
commit
d5c9630fae
2 changed files with 5 additions and 7 deletions
|
|
@ -62,17 +62,19 @@ func (a *App) SSH(ctx context.Context, sshArgs []string, opts sshOptions) (err e
|
|||
return fmt.Errorf("get or choose codespace: %w", err)
|
||||
}
|
||||
|
||||
var debugLogger *fileLogger
|
||||
liveshareLogger := noopLogger()
|
||||
if opts.debug {
|
||||
debugLogger, err = newFileLogger(opts.debugFile)
|
||||
debugLogger, err := newFileLogger(opts.debugFile)
|
||||
if err != nil {
|
||||
return fmt.Errorf("error creating debug logger: %w", err)
|
||||
}
|
||||
defer safeClose(debugLogger, &err)
|
||||
|
||||
liveshareLogger = debugLogger.Logger
|
||||
a.logger.Println("Debug file located at: " + debugLogger.Name())
|
||||
}
|
||||
|
||||
session, err := codespaces.ConnectToLiveshare(ctx, a.logger, debugLogger, a.apiClient, codespace)
|
||||
session, err := codespaces.ConnectToLiveshare(ctx, a.logger, liveshareLogger, a.apiClient, codespace)
|
||||
if err != nil {
|
||||
return fmt.Errorf("error connecting to Live Share: %w", err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -75,10 +75,6 @@ func Connect(ctx context.Context, opts Options) (*Session, error) {
|
|||
return nil, err
|
||||
}
|
||||
|
||||
if opts.Logger == nil {
|
||||
return nil, errors.New("Logger is required")
|
||||
}
|
||||
|
||||
sock := newSocket(uri, opts.TLSConfig)
|
||||
if err := sock.connect(ctx); err != nil {
|
||||
return nil, fmt.Errorf("error connecting websocket: %w", err)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue