mirror of https://github.com/containers/podman.git
Log gvproxy and server9 to file on log-level=debug
Logging to os.Stdout and os.Stderr does not seem to work in Powershell. I am not entirely certain why. Logfiles are the best alternative I can think of. Signed-off-by: Matt Heon <mheon@redhat.com>
This commit is contained in:
parent
d9c388e2fe
commit
7153124f97
|
@ -106,16 +106,12 @@ func client9p(portNum uint32, mountPath string) error {
|
|||
cmd := exec.Command("mount", "-t", "9p", "-o", "trans=fd,rfdno=3,wfdno=3,version=9p2000.L", "9p", mountPath)
|
||||
cmd.ExtraFiles = []*os.File{vsock}
|
||||
|
||||
err := cmd.Run()
|
||||
output, outErr := cmd.CombinedOutput()
|
||||
switch {
|
||||
case outErr != nil:
|
||||
logrus.Errorf("Unable to obtain output of mount command: %v", err)
|
||||
case err == nil:
|
||||
output, err := cmd.CombinedOutput()
|
||||
if err != nil {
|
||||
err = fmt.Errorf("running mount: %w\nOutput: %s", err, string(output))
|
||||
} else {
|
||||
logrus.Debugf("Mount output: %s", string(output))
|
||||
logrus.Infof("Mounted directory %s using 9p", mountPath)
|
||||
default:
|
||||
err = fmt.Errorf("running mount: %w\nOutput: %s", err, string(output))
|
||||
}
|
||||
|
||||
errChan <- err
|
||||
|
|
|
@ -772,8 +772,9 @@ func (m *HyperVMachine) startHostNetworking() (string, machine.APIForwardingStat
|
|||
c := cmd.Cmd(gvproxyBinary)
|
||||
|
||||
if logrus.IsLevelEnabled(logrus.DebugLevel) {
|
||||
c.Stdout = os.Stdout
|
||||
c.Stderr = os.Stderr
|
||||
if err := logCommandToFile(c, "gvproxy.log"); err != nil {
|
||||
return "", 0, err
|
||||
}
|
||||
}
|
||||
|
||||
logrus.Debugf("Starting gvproxy with command: %s %v", gvproxyBinary, c.Args)
|
||||
|
@ -809,8 +810,9 @@ func (m *HyperVMachine) startHostNetworking() (string, machine.APIForwardingStat
|
|||
fsCmd := exec.Command(executable, args...)
|
||||
|
||||
if logrus.IsLevelEnabled(logrus.DebugLevel) {
|
||||
fsCmd.Stdout = os.Stdout
|
||||
fsCmd.Stderr = os.Stderr
|
||||
if err := logCommandToFile(fsCmd, "podman-machine-server9.log"); err != nil {
|
||||
return "", 0, err
|
||||
}
|
||||
}
|
||||
|
||||
if err := fsCmd.Start(); err != nil {
|
||||
|
@ -822,6 +824,25 @@ func (m *HyperVMachine) startHostNetworking() (string, machine.APIForwardingStat
|
|||
return forwardSock, state, nil
|
||||
}
|
||||
|
||||
func logCommandToFile(c *exec.Cmd, filename string) error {
|
||||
dir, err := machine.GetDataDir(machine.HyperVVirt)
|
||||
if err != nil {
|
||||
return fmt.Errorf("obtain machine dir: %w", err)
|
||||
}
|
||||
path := filepath.Join(dir, filename)
|
||||
logrus.Infof("Going to log to %s", path)
|
||||
log, err := os.Create(path)
|
||||
if err != nil {
|
||||
return fmt.Errorf("create log file: %w", err)
|
||||
}
|
||||
defer log.Close()
|
||||
|
||||
c.Stdout = log
|
||||
c.Stderr = log
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *HyperVMachine) setupAPIForwarding(cmd gvproxy.GvproxyCommand) (gvproxy.GvproxyCommand, string, machine.APIForwardingState) {
|
||||
socket, err := m.forwardSocketPath()
|
||||
if err != nil {
|
||||
|
|
Loading…
Reference in New Issue