From a0dda250a573fd1841d8aebe3f7255ddff911126 Mon Sep 17 00:00:00 2001 From: Todd Gruben Date: Mon, 1 Oct 2018 10:11:10 -0500 Subject: [PATCH] converted to pilosa.logger --- translate.go | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/translate.go b/translate.go index cb16de929..be640a777 100644 --- a/translate.go +++ b/translate.go @@ -69,7 +69,7 @@ type TranslateFile struct { Path string mapSize int - + logger Logger // If non-nil, data is streamed from a primary and this is a read-only store. PrimaryTranslateStore TranslateStore primaryID string // unique ID used to identify the primary store @@ -90,6 +90,12 @@ func OptTranslateFileMapSize(mapSize int) TranslateFileOption { return nil } } +func OptTranslateFileLogger(l Logger) TranslateFileOption { + return func(s *TranslateFile) error { + s.logger = l + return nil + } +} // NewTranslateFile returns a new instance of TranslateFile. func NewTranslateFile(opts ...TranslateFileOption) *TranslateFile { @@ -111,6 +117,8 @@ func NewTranslateFile(opts ...TranslateFileOption) *TranslateFile { mapSize: defaultMapSize, + logger: NopLogger, + replicationClosing: make(chan struct{}), primaryStoreEvents: make(chan primaryStoreEvent), @@ -187,12 +195,12 @@ func (s *TranslateFile) handlePrimaryStoreEvent(ev primaryStoreEvent) error { } // Stop translate store replication. - log.Printf("stop monitor replication") + s.logger.Printf("stop monitor replication") close(s.replicationClosing) s.repWG.Wait() // Set the primary node for translate store replication. - log.Printf("set primary translate store to %s", ev.id) + s.logger.Printf("set primary translate store to %s", ev.id) s.primaryID = ev.id if ev.id == "" { s.PrimaryTranslateStore = nil @@ -201,7 +209,7 @@ func (s *TranslateFile) handlePrimaryStoreEvent(ev primaryStoreEvent) error { } // Start translate store replication. Stream from primary, if available. - log.Printf("start monitor replication") + s.logger.Printf("start monitor replication") if s.PrimaryTranslateStore != nil { s.replicationClosing = make(chan struct{}) s.repWG.Add(1)