فهرست منبع

make logger an interface

make logger an interface

add test, use errLog

revert api change, update documentation

rm unneeded SetLogger
Nikolai Berkoff 11 سال پیش
والد
کامیت
0a2774565c
1فایلهای تغییر یافته به همراه9 افزوده شده و 2 حذف شده
  1. 9 2
      sarama.go

+ 9 - 2
sarama.go

@@ -11,10 +11,17 @@ import (
 	"log"
 	"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,
 // 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.
 // 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
 // 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.
 // not recoverable by the caller's goroutine). Defaults to nil, which means panics are not recovered.