1
0
Fork 0

Remove debug

This commit is contained in:
Gregory Eremin 2018-11-14 16:04:09 +01:00
parent b15f4b1877
commit a06e03473b
3 changed files with 9 additions and 38 deletions

View File

@ -48,18 +48,17 @@ func (e *RowsEvent) PeekTableIDAndFlags(connBuff []byte, fd FormatDescription) (
func (e *RowsEvent) Decode(connBuff []byte, fd FormatDescription, td TableDescription) (err error) { func (e *RowsEvent) Decode(connBuff []byte, fd FormatDescription, td TableDescription) (err error) {
defer func() { defer func() {
if errv := recover(); errv != nil { if errv := recover(); errv != nil {
tools.EnableDebug = true fmt.Println("Recovered from panic in RowsEvent.Decode")
tools.Debug("Recovered from panic in RowsEvent.Decode") fmt.Println("Error:", errv)
tools.Debug("Error:", errv) fmt.Println("Format:", fd)
tools.Debug("Format:", fd) fmt.Println("Table:", td)
tools.Debug("Table:", td) fmt.Println("Columns:")
tools.Debug("Columns:")
for _, ctb := range td.ColumnTypes { for _, ctb := range td.ColumnTypes {
tools.Debug(" ", mysql.ColumnType(ctb).String()) fmt.Println(" ", mysql.ColumnType(ctb).String())
} }
tools.Debug("\nBuffer:") fmt.Println("\nBuffer:")
tools.Debug(hex.Dump(connBuff)) fmt.Println(hex.Dump(connBuff))
tools.Debug("Stacktrace:") fmt.Println("Stacktrace:")
debug.PrintStack() debug.PrintStack()
err = errors.New(fmt.Sprint(errv)) err = errors.New(fmt.Sprint(errv))
} }

View File

@ -28,15 +28,12 @@ func NewCommandBuffer(size int) *Buffer {
// Skip advances the cursor by N bytes. // Skip advances the cursor by N bytes.
func (b *Buffer) Skip(n int) { func (b *Buffer) Skip(n int) {
Debugf("Skipped %d bytes: %X\n", n, b.data[b.pos:b.pos+n])
b.pos += n b.pos += n
} }
// Read returns next N bytes and advances the cursor. // Read returns next N bytes and advances the cursor.
func (b *Buffer) Read(n int) []byte { func (b *Buffer) Read(n int) []byte {
b.pos += n 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] 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. // More returns true if there's more to read.
func (b *Buffer) More() bool { func (b *Buffer) More() bool {
Debug("*** BUFFER BOUNDS CHECK len:", len(b.data), "pos:", b.pos)
return b.pos < len(b.data)-1 return b.pos < len(b.data)-1
} }

View File

@ -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...)
}
}