...

Source file src/github.com/redhat-developer/odo/pkg/podman/logs.go

Documentation: github.com/redhat-developer/odo/pkg/podman

     1  package podman
     2  
     3  import (
     4  	"io"
     5  	"os/exec"
     6  
     7  	"k8s.io/klog"
     8  )
     9  
    10  // GetPodLogs returns the logs of the specified pod container.
    11  // All logs for all containers part of the pod are returned if an empty string is provided as container name.
    12  func (o *PodmanCli) GetPodLogs(podName, containerName string, followLog bool) (io.ReadCloser, error) {
    13  	args := []string{"pod", "logs"}
    14  	if followLog {
    15  		args = append(args, "--follow")
    16  	}
    17  	if containerName != "" {
    18  		args = append(args, "--container", podName+"-"+containerName)
    19  	}
    20  	args = append(args, podName)
    21  
    22  	cmd := exec.Command(o.podmanCmd, append(o.containerRunGlobalExtraArgs, args...)...)
    23  	klog.V(3).Infof("executing %v", cmd.Args)
    24  
    25  	out, _ := cmd.StdoutPipe()
    26  	// We get the commbined output as podman logs outputs logs in stdout && stderr (when kubectl outputs all logs on stdout)
    27  	cmd.Stderr = cmd.Stdout
    28  	if err := cmd.Start(); err != nil {
    29  		return nil, err
    30  	}
    31  	return out, nil
    32  }
    33  

View as plain text