diff --git a/main.go b/main.go index 14ec453..0837fc2 100644 --- a/main.go +++ b/main.go @@ -43,5 +43,5 @@ func main() { os.Exit(1) }() - pmuxlib.Run(ctx, cfg) + pmuxlib.Run(ctx, os.Stdout, os.Stderr, cfg) } diff --git a/pmuxlib/pmuxlib.go b/pmuxlib/pmuxlib.go index b9d6f7e..6d5dfaa 100644 --- a/pmuxlib/pmuxlib.go +++ b/pmuxlib/pmuxlib.go @@ -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)