Pass stdout/stderr into pmuxlib.Run

main
Brian Picciano 2 years ago
parent 7a78680038
commit 29241f144a
  1. 2
      main.go
  2. 12
      pmuxlib/pmuxlib.go

@ -43,5 +43,5 @@ func main() {
os.Exit(1)
}()
pmuxlib.Run(ctx, cfg)
pmuxlib.Run(ctx, os.Stdout, os.Stderr, cfg)
}

@ -4,7 +4,7 @@ package pmuxlib
import (
"context"
"os"
"io"
"sync"
)
@ -16,12 +16,16 @@ type Config struct {
// Run runs the given configuration as if this was a real pmux process. It will
// block until the context is canceled and all child processes have been cleaned
// up.
func Run(ctx context.Context, cfg Config) {
func Run(
ctx context.Context,
stdout, stderr io.Writer,
cfg Config,
) {
stdoutLogger := newLogger(os.Stdout, logSepStdout, cfg.TimeFormat)
stdoutLogger := newLogger(stdout, logSepStdout, cfg.TimeFormat)
defer stdoutLogger.Close()
stderrLogger := newLogger(os.Stderr, logSepStderr, cfg.TimeFormat)
stderrLogger := newLogger(stderr, logSepStderr, cfg.TimeFormat)
defer stderrLogger.Close()
sysLogger := stderrLogger.withSep(logSepSys)

Loading…
Cancel
Save