Expose log output writer

This commit is contained in:
tidwall 2021-02-18 15:34:01 -07:00
parent 248c3d8b72
commit b64c87004f
2 changed files with 6 additions and 2 deletions

View File

@ -6,7 +6,6 @@ import (
"errors"
"fmt"
"io/ioutil"
"os"
"sync"
"time"
@ -61,7 +60,7 @@ func (conn *KafkaConn) Send(msg string) error {
conn.t = time.Now()
if log.Level > 2 {
sarama.Logger = lg.New(os.Stdout, "[sarama] ", lg.LstdFlags)
sarama.Logger = lg.New(log.Output(), "[sarama] ", 0)
}
uri := fmt.Sprintf("%s:%d", conn.ep.Kafka.Host, conn.ep.Kafka.Port)

View File

@ -32,6 +32,11 @@ func init() {
SetOutput(os.Stderr)
}
// Output retuns the output writer
func Output() io.Writer {
return wr
}
func log(level int, tag, color string, formatted bool, format string, args ...interface{}) {
if Level < level {
return