]> Cypherpunks.ru repositories - goredo.git/blobdiff - run.go
Prefix target's output with the name
[goredo.git] / run.go
diff --git a/run.go b/run.go
index 816f962e25bc23a18f369872fc8730544078dd5a..3fd4168eef99a4f1feae35302af8abac03157d2e 100644 (file)
--- a/run.go
+++ b/run.go
@@ -628,9 +628,11 @@ func runScript(tgt *Tgt, errs chan error, forced, traced bool) error {
                                line = scanner.Text()
                                if strings.HasPrefix(line, childStderrPrefix) {
                                        line = line[len(childStderrPrefix):]
-                                       LogMutex.Lock()
-                                       os.Stderr.WriteString(StderrPrefix + line + "\n")
-                                       LogMutex.Unlock()
+                                       if StderrPrefix == "" {
+                                               withPrependedTgt(line)
+                                       } else {
+                                               stderrWrite(StderrPrefix + line + "\n")
+                                       }
                                        continue
                                }
                                if fdStderr != nil {
@@ -640,10 +642,13 @@ func runScript(tgt *Tgt, errs chan error, forced, traced bool) error {
                                if StderrSilent {
                                        continue
                                }
-                               if MyPID == 0 {
-                                       tracef(CNone, "%s", line)
+                               if MyPID != 0 {
+                                       line = pid + " " + line
+                               }
+                               if StderrPrefix == "" {
+                                       withPrependedTgt("[" + tgt.rel + "]" + line)
                                } else {
-                                       tracef(CNone, "%s %s", pid, line)
+                                       stderrWrite(StderrPrefix + "[" + tgt.rel + "]" + line + "\n")
                                }
                        }
                        close(stderrTerm)