code: func (c *containerLogManager) compressLog(log string) error {
  	r, err := os.Open(log)
  	if err != nil {
  		return fmt.Errorf("failed to open log %q: %v", log, err)
  	}
  	defer r.Close()
  	tmpLog := log + tmpSuffix
  	f, err := os.OpenFile(tmpLog, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0644)
  	if err != nil {
  		return fmt.Errorf("failed to create temporary log %q: %v", tmpLog, err)
  	}
  	defer func() {
  		// Best effort cleanup of tmpLog.
  		os.Remove(tmpLog)
  	}()
  	defer f.Close()
  	w := gzip.NewWriter(f)
  	defer w.Close()
  	if _, err := io.Copy(w, r); err != nil {
  		return fmt.Errorf("failed to compress %q to %q: %v", log, tmpLog, err)
  	}
  	compressedLog := log + compressSuffix
  	if err := os.Rename(tmpLog, compressedLog); err != nil {
  		return fmt.Errorf("failed to rename %q to %q: %v", tmpLog, compressedLog, err)
  	}
  	// Remove old log file.
  	if err := os.Remove(log); err != nil {
  		return fmt.Errorf("failed to remove log %q after compress: %v", log, err)
  	}
  	return nil
  }
docs: // compressLog compresses a log to log.gz with gzip.