Просмотр исходного кода

make logger an interface

make logger an interface

add test, use errLog

revert api change, update documentation

rm unneeded SetLogger
Nikolai Berkoff 11 лет назад
Родитель
Сommit
0a2774565c
1 измененных файлов с 9 добавлено и 2 удалено
  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.