diff --git a/cdcobserver.go b/cdcobserver.go index dd30969..5a0b0d6 100644 --- a/cdcobserver.go +++ b/cdcobserver.go @@ -54,10 +54,11 @@ func (ob *CDCObserver) Start(ctx context.Context) error { cfg.Addr = fmt.Sprintf("%s:%s", constant.DatabaseHost, port) cfg.User = constant.DatabaseUsername cfg.Password = constant.DatabasePassword - // Exclude mysql system tables - cfg.ExcludeTableRegex = []string{"mysql\\..*"} // Disable dump by setting Dump.ExecutionPath to empty string cfg.Dump.ExecutionPath = "" + // Exclude all databases except cdc-observer + cfg.ExcludeTableRegex = []string{"[^cdc-observer]\\..*"} + cfg.IncludeTableRegex = []string{"cdc-observer\\..*"} c, err := canal.NewCanal(cfg) if err != nil { diff --git a/handler/cdcobserver_handler.go b/handler/cdcobserver_handler.go index 56a265e..780ffda 100644 --- a/handler/cdcobserver_handler.go +++ b/handler/cdcobserver_handler.go @@ -11,7 +11,7 @@ type CDCObserverHandler struct { // todo build a tool for print the CDC event in terminal in table style func (h *CDCObserverHandler) OnRow(e *canal.RowsEvent) error { - log.Infof("%s %v\n", e.Action, e.Rows) + log.Infof("%s %s %v\n", e.Table, e.Action, e.Rows) return nil }