Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: The abstract log interface facilitates external access to logs. #280

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ package memberlist
import (
"fmt"
"io"
"log"
"net"
"os"
"strings"
Expand Down Expand Up @@ -224,7 +223,7 @@ type Config struct {
// this for the internal logger. If Logger is not set, it will fall back to the
// behavior for using LogOutput. You cannot specify both LogOutput and Logger
// at the same time.
Logger *log.Logger
Logger Logger

// Size of Memberlist's internal channel which handles UDP messages. The
// size of this determines the size of the queue which Memberlist will keep
Expand Down
4 changes: 4 additions & 0 deletions logging.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ import (
"net"
)

type Logger interface {
Printf(format string, v ...interface{})
}

func LogAddress(addr net.Addr) string {
if addr == nil {
return "from=<unknown address>"
Expand Down
2 changes: 1 addition & 1 deletion memberlist.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ type Memberlist struct {

broadcasts *TransmitLimitedQueue

logger *log.Logger
logger Logger

// metricLabels is the slice of labels to put on all emitted metrics
metricLabels []metrics.Label
Expand Down
5 changes: 2 additions & 3 deletions net_transport.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"bytes"
"fmt"
"io"
"log"
"net"
"sync"
"sync/atomic"
Expand Down Expand Up @@ -37,7 +36,7 @@ type NetTransportConfig struct {
BindPort int

// Logger is a logger for operator messages.
Logger *log.Logger
Logger Logger

// MetricLabels is a map of optional labels to apply to all metrics
// emitted by this transport.
Expand All @@ -50,7 +49,7 @@ type NetTransport struct {
config *NetTransportConfig
packetCh chan *Packet
streamCh chan net.Conn
logger *log.Logger
logger Logger
wg sync.WaitGroup
tcpListeners []*net.TCPListener
udpListeners []*net.UDPConn
Expand Down