Skip to content

Commit

Permalink
refactor(log): ConnectToLogs
Browse files Browse the repository at this point in the history
Now it is a proxy for `RemoteSub("sub log-drain -k")`
  • Loading branch information
neurosnap committed Nov 12, 2024
1 parent 57a5727 commit 866d44c
Showing 1 changed file with 1 addition and 27 deletions.
28 changes: 1 addition & 27 deletions log/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

0 comments on commit 866d44c

Please sign in to comment.