From 866d44c53659c39e5e189fb70525371ecd6b7935 Mon Sep 17 00:00:00 2001 From: Eric Bower Date: Tue, 12 Nov 2024 10:08:41 -0500 Subject: [PATCH] refactor(log): `ConnectToLogs` Now it is a proxy for `RemoteSub("sub log-drain -k")` --- log/log.go | 28 +--------------------------- 1 file changed, 1 insertion(+), 27 deletions(-) diff --git a/log/log.go b/log/log.go index 361f6bd..98bfddc 100644 --- a/log/log.go +++ b/log/log.go @@ -272,31 +272,5 @@ var _ io.Writer = (*PubSubLogWriter)(nil) var _ slog.Handler = (*MultiHandler)(nil) func ConnectToLogs(ctx context.Context, connectionInfo *pubsub.RemoteClientInfo) (io.Reader, error) { - sshClient, err := pubsub.CreateRemoteClient(connectionInfo) - if err != nil { - return nil, err - } - - session, err := sshClient.NewSession() - if err != nil { - return nil, err - } - - stdoutPipe, err := session.StdoutPipe() - if err != nil { - return nil, err - } - - err = session.Start("sub log-drain -k") - if err != nil { - return nil, err - } - - go func() { - <-ctx.Done() - session.Close() - sshClient.Close() - }() - - return stdoutPipe, nil + return pubsub.RemoteSub("sub log-drain -k", ctx, connectionInfo) }