Browse Source

Merge pull request #157 from nikolai-b/master

Make logger an interface
Willem van Bergen 11 năm trước cách đây
mục cha
commit
e9afaa6fc0
1 tập tin đã thay đổi với 9 bổ sung2 xóa
  1. 9 2
      sarama.go

+ 9 - 2
sarama.go

@@ -11,10 +11,17 @@ import (
 	"log"
 )
 
-// Logger is the instance of golang's log.Logger that Sarama writes connection
+// Logger is the instance of a StdLogger interface that Sarama writes connection
 // management events to. By default it is set to discard all log messages via ioutil.Discard,
 // but you can set it to redirect wherever you want.
-var Logger = log.New(ioutil.Discard, "[Sarama] ", log.LstdFlags)
+var Logger StdLogger = log.New(ioutil.Discard, "[Sarama] ", log.LstdFlags)
+
+// StdLogger is used to log error messages.
+type StdLogger interface {
+	Print(v ...interface{})
+	Printf(format string, v ...interface{})
+	Println(v ...interface{})
+}
 
 // PanicHandler is called for recovering from panics spawned internally to the library (and thus
 // not recoverable by the caller's goroutine). Defaults to nil, which means panics are not recovered.