From a06e03473b7b8e80ecff2574f6b3493c7c763c6a Mon Sep 17 00:00:00 2001 From: Gregory Eremin Date: Wed, 14 Nov 2018 16:04:09 +0100 Subject: [PATCH] Remove debug --- binlog/event_rows.go | 19 +++++++++---------- tools/buffer.go | 4 ---- tools/debug.go | 24 ------------------------ 3 files changed, 9 insertions(+), 38 deletions(-) delete mode 100644 tools/debug.go diff --git a/binlog/event_rows.go b/binlog/event_rows.go index bc6f814..5ea075f 100644 --- a/binlog/event_rows.go +++ b/binlog/event_rows.go @@ -48,18 +48,17 @@ func (e *RowsEvent) PeekTableIDAndFlags(connBuff []byte, fd FormatDescription) ( func (e *RowsEvent) Decode(connBuff []byte, fd FormatDescription, td TableDescription) (err error) { defer func() { if errv := recover(); errv != nil { - tools.EnableDebug = true - tools.Debug("Recovered from panic in RowsEvent.Decode") - tools.Debug("Error:", errv) - tools.Debug("Format:", fd) - tools.Debug("Table:", td) - tools.Debug("Columns:") + fmt.Println("Recovered from panic in RowsEvent.Decode") + fmt.Println("Error:", errv) + fmt.Println("Format:", fd) + fmt.Println("Table:", td) + fmt.Println("Columns:") for _, ctb := range td.ColumnTypes { - tools.Debug(" ", mysql.ColumnType(ctb).String()) + fmt.Println(" ", mysql.ColumnType(ctb).String()) } - tools.Debug("\nBuffer:") - tools.Debug(hex.Dump(connBuff)) - tools.Debug("Stacktrace:") + fmt.Println("\nBuffer:") + fmt.Println(hex.Dump(connBuff)) + fmt.Println("Stacktrace:") debug.PrintStack() err = errors.New(fmt.Sprint(errv)) } diff --git a/tools/buffer.go b/tools/buffer.go index a6e40e8..5798220 100644 --- a/tools/buffer.go +++ b/tools/buffer.go @@ -28,15 +28,12 @@ func NewCommandBuffer(size int) *Buffer { // Skip advances the cursor by N bytes. func (b *Buffer) Skip(n int) { - Debugf("Skipped %d bytes: %X\n", n, b.data[b.pos:b.pos+n]) b.pos += n } // Read returns next N bytes and advances the cursor. func (b *Buffer) Read(n int) []byte { b.pos += n - - Debugf("Read %d bytes: %X\n", n, b.data[b.pos-n:b.pos]) return b.data[b.pos-n : b.pos] } @@ -47,7 +44,6 @@ func (b *Buffer) Cur() []byte { // More returns true if there's more to read. func (b *Buffer) More() bool { - Debug("*** BUFFER BOUNDS CHECK len:", len(b.data), "pos:", b.pos) return b.pos < len(b.data)-1 } diff --git a/tools/debug.go b/tools/debug.go deleted file mode 100644 index 42ee887..0000000 --- a/tools/debug.go +++ /dev/null @@ -1,24 +0,0 @@ -package tools - -import ( - "fmt" - - "github.com/localhots/pretty" -) - -// EnableDebug controls debug output. -var EnableDebug = false - -// Debug ... -func Debug(vals ...interface{}) { - if EnableDebug { - pretty.Println(vals...) - } -} - -// Debugf ... -func Debugf(format string, args ...interface{}) { - if EnableDebug { - fmt.Printf(format, args...) - } -}