From 6983deefcde31f8a142ea5285a530f58043e64c7 Mon Sep 17 00:00:00 2001 From: Lyon Hill Date: Wed, 1 Mar 2017 09:27:42 -0700 Subject: [PATCH 1/2] modify the display summary so it works better with cutoff lines --- util/display/summary.go | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/util/display/summary.go b/util/display/summary.go index b6fe4eb1..8c443e3c 100644 --- a/util/display/summary.go +++ b/util/display/summary.go @@ -8,6 +8,8 @@ import ( "strings" "time" + "github.com/jcelliott/lumber" + "github.com/lyondhill/vtclean" "github.com/nanobox-io/nanobox/util" ) @@ -200,6 +202,7 @@ func (s *Summarizer) handleEvent(event *sEventOp) { // handleLog sets the detail line and refreshes the summary func (s *Summarizer) handleLog(data string) { + lumber.Debug("%q", data) msg := s.leftover s.leftover = "" @@ -208,10 +211,22 @@ func (s *Summarizer) handleLog(data string) { return c == '\n' || c == '\r' } + // get the line we were seeing before the new data + prevLine := s.detail + // iterate through the lines, we'll keep the last line that has data lines := strings.FieldsFunc(msg+data, f) - for _, line := range lines { - + for i, line := range lines { + + // check to see if we are we are at the last element and determin + // if we should be displaying it + if (len(lines) - 1) == i { + // if there is any data and it doesnt end with a newline + if !(strings.HasSuffix(data, "\n") || strings.HasSuffix(data, "\r")) { + // do not display the last incomplete line + continue + } + } // first we need to remove escape sequences line = EscSeqRegex.ReplaceAllString(line, "") @@ -221,13 +236,18 @@ func (s *Summarizer) handleLog(data string) { // then we need to remove any leading whitespace line = LogStripRegex.ReplaceAllString(line, "") + // if empty or no change we wont reprint if len(line) == 0 { continue } s.detail = line + } + + // if the new data actuall changed the line we are displaying show it + if prevLine != s.detail { s.reset() - s.print() + s.print() } // if there is any data and it doesnt end with a newline From 85a011d92898e5b99ae2663aada029cbd7edbae6 Mon Sep 17 00:00:00 2001 From: lyondhill Date: Wed, 1 Mar 2017 10:12:10 -0700 Subject: [PATCH 2/2] remove lumber --- util/display/summary.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/util/display/summary.go b/util/display/summary.go index 8c443e3c..de8ee0e9 100644 --- a/util/display/summary.go +++ b/util/display/summary.go @@ -8,7 +8,7 @@ import ( "strings" "time" - "github.com/jcelliott/lumber" + // "github.com/jcelliott/lumber" "github.com/lyondhill/vtclean" "github.com/nanobox-io/nanobox/util" @@ -202,7 +202,7 @@ func (s *Summarizer) handleEvent(event *sEventOp) { // handleLog sets the detail line and refreshes the summary func (s *Summarizer) handleLog(data string) { - lumber.Debug("%q", data) + // lumber.Debug("%q", data) msg := s.leftover s.leftover = ""