Logs
Patchsets
Range Diff ↕ rd-60
1: 57a5727 = 1: 57a5727 refactor: create remote client lib
-: ------- > 2: 67d38ff refactor(log): rm ConnectToLogs
Range Diff ↕ rd-61
1: 57a5727 = 1: 57a5727 refactor: create remote client lib
2: 67d38ff = 2: 67d38ff refactor(log): rm ConnectToLogs
-: ------- > 3: 97084b4 refactor(log): preserve `ConnectToLogs` but make it a convenient proxy
Range Diff ↕ rd-62
1: 57a5727 = 1: 57a5727 refactor: create remote client lib
2: 67d38ff ! 2: 866d44c refactor(log): `ConnectToLogs`
3: 97084b4 < -: ------- refactor(log): preserve `ConnectToLogs` but make it a convenient proxy
Range-diff rd-62
- title
- refactor: create remote client lib
- description
-
Patch equal
- old #1
57a5727
- new #1
57a5727
- title
- refactor(log): `ConnectToLogs`
- description
-
Patch changed
- old #2
67d38ff
- new #2
866d44c
- title
- refactor(log): preserve `ConnectToLogs` but make it a convenient proxy
- description
-
Patch removed
- old #3
97084b4
- new #0
(none)
1: 57a5727 = 1: 57a5727 refactor: create remote client lib
2: 67d38ff ! 2: 866d44c refactor(log): `ConnectToLogs`
log/log.go
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)
log/log.go
var _ slog.Handler = (*MultiHandler)(nil) - -func ConnectToLogs(ctx context.Context, connectionInfo *pubsub.RemoteClientInfo) (io.Reader, error) { 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) }
3: 97084b4 < -: ------- refactor(log): preserve `ConnectToLogs` but make it a convenient proxy