code: func (m *Manager) configureLogDir(id string, cmd *exec.Cmd) error {
  	// Create the log directory
  	logDir := ""
  	if m.DataDir != "" {
  		logDir = filepath.Join(m.DataDir, "logs")
  		if err := os.MkdirAll(logDir, 0700); err != nil {
  			return err
  		}
  	}
  
  	// Configure the stdout, stderr paths
  	stdoutPath := logPath(logDir, id, "stdout")
  	stderrPath := logPath(logDir, id, "stderr")
  
  	// Open the files. We want to append to each. We expect these files
  	// to be rotated by some external process.
  	stdoutF, err := os.OpenFile(stdoutPath, os.O_APPEND|os.O_WRONLY|os.O_CREATE, 0600)
  	if err != nil {
  		return fmt.Errorf("error creating stdout file: %s", err)
  	}
  	stderrF, err := os.OpenFile(stderrPath, os.O_APPEND|os.O_WRONLY|os.O_CREATE, 0600)
  	if err != nil {
  		// Don't forget to close stdoutF which successfully opened
  		stdoutF.Close()
  
  		return fmt.Errorf("error creating stderr file: %s", err)
  	}
  
  	cmd.Stdout = stdoutF
  	cmd.Stderr = stderrF
  	return nil
  }
docs: // configureLogDir sets up the file descriptors to stdout/stderr so that
  // they log to the proper file path for the given service ID.