code: func muxOutput(streamLabel string, lines chan []byte, clients <-chan net.Conn, targets <-chan io.WriteCloser) {
  	var logs []io.WriteCloser
  	var conns []io.WriteCloser
  
  	writeAndFilter := func(wc io.WriteCloser, line []byte) bool {
  		_, err := wc.Write(line)
  		if err != nil {
  			wc.Close()
  		}
  		return err != nil
  	}
  
  	logsWriteAndFilter := func(wc io.WriteCloser, line []byte) bool {
  		out := []byte(fmt.Sprintf("%s %s %s", time.Now().Format(time.RFC3339Nano), streamLabel, line))
  		return writeAndFilter(wc, out)
  	}
  
  	for {
  		select {
  		// an incoming output line to multiplex
  		// TODO(lucab): ordered non-blocking writes
  		case l := <-lines:
  			conns = filterTargets(conns, l, writeAndFilter)
  			logs = filterTargets(logs, l, logsWriteAndFilter)
  
  		// a new remote client
  		case c := <-clients:
  			conns = append(conns, c)
  
  		// a new local log target
  		case t := <-targets:
  			logs = append(logs, t)
  		}
  	}
  }
docs: // muxOutput receives remote clients and local log targets,
  // multiplexing output lines to them