code: func LogWriter() (w io.WriteCloser, err error) {
  	w = multiWriteCloser{
  		w: os.Stderr,
  		// Because we don't actually want to close os.Stderr (which we could).
  		closer: types.NopCloser,
  	}
  	if !env.OnGCE() {
  		return
  	}
  	projID, err := metadata.ProjectID()
  	if projID == "" {
  		log.Printf("Error getting project ID: %v", err)
  		return
  	}
  	scopes, _ := metadata.Scopes("default")
  	haveScope := func(scope string) bool {
  		for _, x := range scopes {
  			if x == scope {
  				return true
  			}
  		}
  		return false
  	}
  	if !haveScope(logging.WriteScope) {
  		return nil, fmt.Errorf("when this Google Compute Engine VM instance was created, it wasn't granted enough access to use Google Cloud Logging (Scope URL: %v)", logging.WriteScope)
  	}
  
  	ctx := context.Background()
  	logc, err := logging.NewClient(ctx, projID)
  	if err != nil {
  		return nil, fmt.Errorf("error creating Google logging client: %v", err)
  	}
  	if err := logc.Ping(ctx); err != nil {
  		return nil, fmt.Errorf("Google logging client not ready (ping failed): %v", err)
  	}
  	logw := writer{
  		severity: logging.Debug,
  		logger:   logc.Logger("perkeepd-stderr"),
  	}
  	return multiWriteCloser{
  		w:      io.MultiWriter(w, logw),
  		closer: logc,
  	}, nil
  }
docs: // LogWriter returns an environment-specific io.WriteCloser suitable for passing
  // to log.SetOutput. It will also include writing to os.Stderr as well.
  // Since it might be writing to a Google Cloud Logger, it is the responsibility
  // of the caller to Close it when needed, to flush the last log entries.