@@ -11,7 +11,6 @@ import (
1111 "github.com/google/uuid"
1212 "github.com/pingcap/errors"
1313 "github.com/pingcap/parser/ast"
14- "github.com/siddontang/go-log/log"
1514)
1615
1716func (c * Canal ) startSyncer () (* replication.BinlogStreamer , error ) {
@@ -22,15 +21,15 @@ func (c *Canal) startSyncer() (*replication.BinlogStreamer, error) {
2221 if err != nil {
2322 return nil , errors .Errorf ("start sync replication at binlog %v error %v" , pos , err )
2423 }
25- log .Infof ("start sync binlog at binlog file %v" , pos )
24+ c . cfg . Logger .Infof ("start sync binlog at binlog file %v" , pos )
2625 return s , nil
2726 } else {
2827 gsetClone := gset .Clone ()
2928 s , err := c .syncer .StartSyncGTID (gset )
3029 if err != nil {
3130 return nil , errors .Errorf ("start sync replication at GTID set %v error %v" , gset , err )
3231 }
33- log .Infof ("start sync binlog at GTID set %v" , gsetClone )
32+ c . cfg . Logger .Infof ("start sync binlog at GTID set %v" , gsetClone )
3433 return s , nil
3534 }
3635}
@@ -65,7 +64,7 @@ func (c *Canal) runSyncBinlog() error {
6564 switch e := ev .Event .(type ) {
6665 case * replication.RotateEvent :
6766 fakeRotateLogName = string (e .NextLogName )
68- log .Infof ("received fake rotate event, next log name is %s" , e .NextLogName )
67+ c . cfg . Logger .Infof ("received fake rotate event, next log name is %s" , e .NextLogName )
6968 }
7069
7170 continue
@@ -76,6 +75,7 @@ func (c *Canal) runSyncBinlog() error {
7675 pos := c .master .Position ()
7776
7877 curPos := pos .Pos
78+
7979 // next binlog pos
8080 pos .Pos = ev .Header .LogPos
8181
@@ -92,7 +92,7 @@ func (c *Canal) runSyncBinlog() error {
9292 case * replication.RotateEvent :
9393 pos .Name = string (e .NextLogName )
9494 pos .Pos = uint32 (e .Position )
95- log .Infof ("rotate binlog to %s" , pos )
95+ c . cfg . Logger .Infof ("rotate binlog to %s" , pos )
9696 savePos = true
9797 force = true
9898 if err = c .eventHandler .OnRotate (e ); err != nil {
@@ -107,7 +107,7 @@ func (c *Canal) runSyncBinlog() error {
107107 if e != ErrExcludedTable &&
108108 e != schema .ErrTableNotExist &&
109109 e != schema .ErrMissingTableMeta {
110- log .Errorf ("handle rows event at (%s, %d) error %v" , pos .Name , curPos , err )
110+ c . cfg . Logger .Errorf ("handle rows event at (%s, %d) error %v" , pos .Name , curPos , err )
111111 return errors .Trace (err )
112112 }
113113 }
@@ -142,7 +142,7 @@ func (c *Canal) runSyncBinlog() error {
142142 case * replication.QueryEvent :
143143 stmts , _ , err := c .parser .Parse (string (e .Query ), "" , "" )
144144 if err != nil {
145- log .Errorf ("parse query(%s) err %v, will skip this event" , e .Query , err )
145+ c . cfg . Logger .Errorf ("parse query(%s) err %v, will skip this event" , e .Query , err )
146146 continue
147147 }
148148 for _ , stmt := range stmts {
@@ -230,7 +230,7 @@ func parseStmt(stmt ast.StmtNode) (ns []*node) {
230230
231231func (c * Canal ) updateTable (db , table string ) (err error ) {
232232 c .ClearTableCache ([]byte (db ), []byte (table ))
233- log .Infof ("table structure changed, clear table cache: %s.%s\n " , db , table )
233+ c . cfg . Logger .Infof ("table structure changed, clear table cache: %s.%s\n " , db , table )
234234 if err = c .eventHandler .OnTableChanged (db , table ); err != nil && errors .Cause (err ) != schema .ErrTableNotExist {
235235 return errors .Trace (err )
236236 }
@@ -291,7 +291,7 @@ func (c *Canal) WaitUntilPos(pos mysql.Position, timeout time.Duration) error {
291291 if curPos .Compare (pos ) >= 0 {
292292 return nil
293293 } else {
294- log .Debugf ("master pos is %v, wait catching %v" , curPos , pos )
294+ c . cfg . Logger .Debugf ("master pos is %v, wait catching %v" , curPos , pos )
295295 time .Sleep (100 * time .Millisecond )
296296 }
297297 }
0 commit comments