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) {
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))
}

View File

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

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