Debug logging
This commit is contained in:
parent
7b94053376
commit
d4f826d44b
@ -376,35 +376,41 @@ func (q System) ssh(user string) (client *ssh.Client, err error) {
|
|||||||
|
|
||||||
// Command executes shell commands on qemu system
|
// Command executes shell commands on qemu system
|
||||||
func (q System) Command(user, cmd string) (output string, err error) {
|
func (q System) Command(user, cmd string) (output string, err error) {
|
||||||
q.Log.With().Str("kernel", q.kernel.KernelPath).
|
flog := q.Log.With().Str("kernel", q.kernel.KernelPath).
|
||||||
Str("user", user).
|
Str("user", user).
|
||||||
Str("cmd", cmd)
|
Str("cmd", cmd).
|
||||||
|
Logger()
|
||||||
|
|
||||||
q.Log.Debug().Msg("qemu command")
|
flog.Debug().Msg("qemu command")
|
||||||
|
|
||||||
client, err := q.ssh(user)
|
client, err := q.ssh(user)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
flog.Debug().Err(err).Msg("ssh connection")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
defer client.Close()
|
defer client.Close()
|
||||||
|
|
||||||
session, err := client.NewSession()
|
session, err := client.NewSession()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
flog.Debug().Err(err).Msg("new session")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
stdout, err := session.StdoutPipe()
|
stdout, err := session.StdoutPipe()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
flog.Debug().Err(err).Msg("get stdout pipe")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
stderr, err := session.StderrPipe()
|
stderr, err := session.StderrPipe()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
flog.Debug().Err(err).Msg("get stderr pipe")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
err = session.Start(cmd)
|
err = session.Start(cmd)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
flog.Debug().Err(err).Msg("start session")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -413,7 +419,7 @@ func (q System) Command(user, cmd string) (output string, err error) {
|
|||||||
for scanner.Scan() {
|
for scanner.Scan() {
|
||||||
m := scanner.Text()
|
m := scanner.Text()
|
||||||
output += m + "\n"
|
output += m + "\n"
|
||||||
q.Log.Trace().Str("stdout", m).Msg("qemu command")
|
flog.Trace().Str("stdout", m).Msg("qemu command")
|
||||||
}
|
}
|
||||||
output = strings.TrimSuffix(output, "\n")
|
output = strings.TrimSuffix(output, "\n")
|
||||||
}()
|
}()
|
||||||
@ -424,7 +430,7 @@ func (q System) Command(user, cmd string) (output string, err error) {
|
|||||||
m := scanner.Text()
|
m := scanner.Text()
|
||||||
output += m + "\n"
|
output += m + "\n"
|
||||||
// Note: it prints stderr as stdout
|
// Note: it prints stderr as stdout
|
||||||
q.Log.Trace().Str("stdout", m).Msg("qemu command")
|
flog.Trace().Str("stdout", m).Msg("qemu command")
|
||||||
}
|
}
|
||||||
output = strings.TrimSuffix(output, "\n")
|
output = strings.TrimSuffix(output, "\n")
|
||||||
}()
|
}()
|
||||||
|
Loading…
Reference in New Issue
Block a user