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

Make logger require an interface instead of a concrete implementation #732

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Make logger require an interface instead of a concrete implementation
It is much easier to integrate 3rd-party log implementations by requiring
an interface instead of requiring a Logger struct (which implements this
interface).
  • Loading branch information
mcuelenaere committed Sep 26, 2022
commit 990004c937505d90732e8e7f004640bfa85833bf
3 changes: 2 additions & 1 deletion canal/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"github.com/go-mysql-org/go-mysql/mysql"
"github.com/pingcap/errors"
"github.com/siddontang/go-log/log"
"github.com/siddontang/go-log/loggers"
)

type DumpConfig struct {
Expand Down Expand Up @@ -91,7 +92,7 @@ type Config struct {
TLSConfig *tls.Config

//Set Logger
Logger *log.Logger
Logger loggers.Advanced

//Set Dialer
Dialer client.Dialer
Expand Down
4 changes: 2 additions & 2 deletions canal/master.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"sync"

"github.com/go-mysql-org/go-mysql/mysql"
"github.com/siddontang/go-log/log"
"github.com/siddontang/go-log/loggers"
)

type masterInfo struct {
Expand All @@ -16,7 +16,7 @@ type masterInfo struct {

timestamp uint32

logger *log.Logger
logger loggers.Advanced
}

func (m *masterInfo) Update(pos mysql.Position) {
Expand Down
4 changes: 3 additions & 1 deletion replication/binlogsyncer.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import (
"sync"
"time"

"github.com/siddontang/go-log/loggers"

"github.com/google/uuid"
"github.com/pingcap/errors"
"github.com/siddontang/go-log/log"
Expand Down Expand Up @@ -112,7 +114,7 @@ type BinlogSyncerConfig struct {
Option func(*client.Conn) error

// Set Logger
Logger *log.Logger
Logger loggers.Advanced

// Set Dialer
Dialer client.Dialer
Expand Down