more debug logging

This commit is contained in:
Pavel Vorobyov
2019-09-24 15:00:34 +03:00
parent d1b9cdc054
commit e4d225c825
3 changed files with 13 additions and 7 deletions

View File

@@ -189,6 +189,9 @@ func RunCollapse(hosts []string, cmd string) *ExecResult {
case d := <-pool.Data:
switch d.Type {
case MTData:
if currentDebug {
log.Debugf("DATASTREAM @ %s:\n%v\n[%v]\n", d.Hostname, d.Data, string(d.Data))
}
outputs[d.Hostname] += string(d.Data)
logData := make([]byte, len(d.Data))
copy(logData, d.Data)
@@ -198,7 +201,7 @@ func RunCollapse(hosts []string, cmd string) *ExecResult {
writeHostOutput(d.Hostname, logData)
case MTDebug:
if currentDebug {
log.Debugf("DATASTREAM @ %s\n%v\n[%v]", d.Hostname, d.Data, string(d.Data))
log.Debugf("DEBUGSTREAM @ %s:\n%v\n[%v]\n", d.Hostname, d.Data, string(d.Data))
}
case MTCopyFinished:
if d.StatusCode == 0 {
@@ -226,12 +229,15 @@ func RunCollapse(hosts []string, cmd string) *ExecResult {
bar.Finish()
}
for k, v := range outputs {
_, found := r.Outputs[v]
for host, hostOutput := range outputs {
_, found := r.Outputs[hostOutput]
if !found {
r.Outputs[v] = make([]string, 0)
if currentDebug {
log.Debugf("Collapse mode found a new output:\n\"%s\"\n%v\n", hostOutput, []byte(hostOutput))
}
r.Outputs[hostOutput] = make([]string, 0)
}
r.Outputs[v] = append(r.Outputs[v], k)
r.Outputs[hostOutput] = append(r.Outputs[hostOutput], host)
}
return r

View File

@@ -74,7 +74,7 @@ execLoop:
continue
}
w.data <- &Message{buf, MTDebug, task.Hostname, -1}
w.data <- &Message{buf[:n], MTDebug, task.Hostname, -1}
msgCount++
chunks := bytes.SplitAfter(buf[:n], []byte{'\n'})

View File

@@ -154,7 +154,7 @@ func (w *Worker) run() {
// does the task have anything to run?
if task.Cmd != "" {
log.Debugf("WRK[%d] runcmd(%s) at %s", task.Cmd, task.Hostname)
log.Debugf("WRK[%d] runcmd(%s) at %s", w.id, task.Cmd, task.Hostname)
result = w.runcmd(task)
w.data <- &Message{nil, MTExecFinished, task.Hostname, result}
}