[ARVADOS] updated: b5bbdf7032e8c2e31a6afeae00e388d7216db63d

Git user git at public.curoverse.com
Thu Jun 30 11:06:34 EDT 2016


Summary of changes:
 services/crunch-run/logging.go      | 50 +++++++++++++++++++++----------------
 services/crunch-run/logging_test.go |  6 ++++-
 2 files changed, 34 insertions(+), 22 deletions(-)

       via  b5bbdf7032e8c2e31a6afeae00e388d7216db63d (commit)
       via  fc8699fde83da5983d98d41a38533b33aec94382 (commit)
       via  d541c980b22b7414147317f7a05aa67170425a9c (commit)
      from  1467ece28d0f09b59296dcd9a2ce848b3a505c20 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.


commit b5bbdf7032e8c2e31a6afeae00e388d7216db63d
Author: Tom Clegg <tom at curoverse.com>
Date:   Thu Jun 30 11:05:37 2016 -0400

    8016: Fix some error checking in ThrottledLogger.

diff --git a/services/crunch-run/logging.go b/services/crunch-run/logging.go
index 9b19bf0..db9d101 100644
--- a/services/crunch-run/logging.go
+++ b/services/crunch-run/logging.go
@@ -46,8 +46,9 @@ func RFC3339Timestamp(t time.Time) string {
 	return t.Format(RFC3339NanoFixed)
 }
 
-// Write to the internal buffer.  Prepend a timestamp to each line of the input
-// data.
+// Write prepends a timestamp to each line of the input data and
+// appends to the internal buffer. Each line is also logged to
+// tl.Immediate, if tl.Immediate is not nil.
 func (tl *ThrottledLogger) Write(p []byte) (n int, err error) {
 	tl.Mutex.Lock()
 	if tl.buf == nil {
@@ -57,13 +58,20 @@ func (tl *ThrottledLogger) Write(p []byte) (n int, err error) {
 
 	now := tl.Timestamper(time.Now().UTC())
 	sc := bufio.NewScanner(bytes.NewBuffer(p))
-	for sc.Scan() {
-		_, err = fmt.Fprintf(tl.buf, "%s %s\n", now, sc.Text())
+	for err == nil && sc.Scan() {
+		out := fmt.Sprintf("%s %s\n", now, sc.Bytes())
 		if tl.Immediate != nil {
-			tl.Immediate.Printf("%s %s\n", now, sc.Text())
+			tl.Immediate.Print(out[:len(out)-1])
 		}
+		_, err = io.WriteString(tl.buf, out)
 	}
-	return len(p), err
+	if err == nil {
+		err = sc.Err()
+		if err == nil {
+			n = len(p)
+		}
+	}
+	return
 }
 
 // Periodically check the current buffer; if not empty, send it on the

commit fc8699fde83da5983d98d41a38533b33aec94382
Author: Tom Clegg <tom at curoverse.com>
Date:   Thu Jun 30 10:41:07 2016 -0400

    8016: Fixup comment grammar and weird variable name.

diff --git a/services/crunch-run/logging.go b/services/crunch-run/logging.go
index 8d6cce8..9b19bf0 100644
--- a/services/crunch-run/logging.go
+++ b/services/crunch-run/logging.go
@@ -157,17 +157,18 @@ func ReadWriteLines(in io.Reader, writer io.Writer, done chan<- bool) {
 // (b) batches log messages and only calls the underlying Writer at most once
 // per second.
 func NewThrottledLogger(writer io.WriteCloser) *ThrottledLogger {
-	alw := &ThrottledLogger{}
-	alw.flusherDone = make(chan bool)
-	alw.writer = writer
-	alw.Logger = log.New(alw, "", 0)
-	alw.Timestamper = RFC3339Timestamp
-	go alw.flusher()
-	return alw
+	tl := &ThrottledLogger{}
+	tl.flusherDone = make(chan bool)
+	tl.writer = writer
+	tl.Logger = log.New(tl, "", 0)
+	tl.Timestamper = RFC3339Timestamp
+	go tl.flusher()
+	return tl
 }
 
-// ArvLogWriter implements a writer that writes to each of a WriteCloser
-// (typically CollectionFileWriter) and creates an API server log entry.
+// ArvLogWriter is an io.WriteCloser that processes each write by
+// writing it through to another io.WriteCloser (typically a
+// CollectionFileWriter) and creating an Arvados log entry.
 type ArvLogWriter struct {
 	ArvClient     IArvadosClient
 	UUID          string

commit d541c980b22b7414147317f7a05aa67170425a9c
Author: Tom Clegg <tom at curoverse.com>
Date:   Thu Jun 30 10:26:07 2016 -0400

    8016: Fix timestamp format (add missing nanoseconds), and use it in tests.

diff --git a/services/crunch-run/logging.go b/services/crunch-run/logging.go
index 20928db..8d6cce8 100644
--- a/services/crunch-run/logging.go
+++ b/services/crunch-run/logging.go
@@ -38,13 +38,12 @@ type ThrottledLogger struct {
 	Immediate *log.Logger
 }
 
-// RFC3339Fixed is a fixed-width version of RFC3339 with microsecond precision,
-// because the RFC3339Nano format isn't fixed width.
-const RFC3339Fixed = "2006-01-02T15:04:05.000000Z07:00"
+// RFC3339NanoFixed is a fixed-width version of time.RFC3339Nano.
+const RFC3339NanoFixed = "2006-01-02T15:04:05.000000000Z07:00"
 
-// RFC3339Timestamp return a RFC3339 formatted timestamp using RFC3339Fixed
-func RFC3339Timestamp(now time.Time) string {
-	return now.Format(RFC3339Fixed)
+// RFC3339Timestamp formats t as RFC3339NanoFixed.
+func RFC3339Timestamp(t time.Time) string {
+	return t.Format(RFC3339NanoFixed)
 }
 
 // Write to the internal buffer.  Prepend a timestamp to each line of the input
diff --git a/services/crunch-run/logging_test.go b/services/crunch-run/logging_test.go
index bb3123a..ceb8ca8 100644
--- a/services/crunch-run/logging_test.go
+++ b/services/crunch-run/logging_test.go
@@ -16,7 +16,11 @@ type TestTimestamper struct {
 
 func (this *TestTimestamper) Timestamp(t time.Time) string {
 	this.count += 1
-	return fmt.Sprintf("2015-12-29T15:51:45.%09dZ", this.count)
+	t, err := time.ParseInLocation(time.RFC3339Nano, fmt.Sprintf("2015-12-29T15:51:45.%09dZ", this.count), t.Location())
+	if err != nil {
+		panic(err)
+	}
+	return RFC3339Timestamp(t)
 }
 
 // Gocheck boilerplate

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list