Skip to content

Commit

Permalink
cleanup stdout output for jobs; get rid of final empty linebreak and …
Browse files Browse the repository at this point in the history
…give lines the correct timestamp for that line
  • Loading branch information
SergeyTsalkov committed Sep 26, 2016
1 parent 963b161 commit c3e0a0e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
8 changes: 2 additions & 6 deletions src/brooce/runnabletask/stdoutlog.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,16 @@ import (

type runnableTaskStdoutLog struct {
*RunnableTask
firstLineDone bool
}

func (task *runnableTaskStdoutLog) Write(p []byte) (lenP int, err error) {
lenP = len(p)
str := string(p)

prefix := fmt.Sprintf("%s> ", time.Now().Format(tsFormat))
str = strings.TrimSpace(str)
str = strings.Replace(str, "\n", "\n"+prefix, -1)

if !task.firstLineDone {
str = prefix + str
task.firstLineDone = true
}
str = prefix + str + "\n"

_, err = task.RunnableTask.Write([]byte(str))
return
Expand Down
2 changes: 1 addition & 1 deletion src/brooce/runnabletask/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func (task *RunnableTask) Run() (exitCode int, err error) {
finishtime := time.Now()
runtime := finishtime.Sub(starttime)

task.WriteLog(fmt.Sprintf("\n*** COMPLETED_AT:[%s] RUNTIME:[%s] EXITCODE:[%d] ERROR:[%v]\n",
task.WriteLog(fmt.Sprintf("*** COMPLETED_AT:[%s] RUNTIME:[%s] EXITCODE:[%d] ERROR:[%v]\n",
finishtime.Format(tsFormat),
runtime,
exitCode,
Expand Down

0 comments on commit c3e0a0e

Please sign in to comment.