Better debug output

This commit is contained in:
Jae Kwon 2014-12-28 16:26:53 -08:00
parent c6c465402e
commit b0755c938a
6 changed files with 31 additions and 13 deletions

13
Makefile Normal file
View File

@ -0,0 +1,13 @@
all: build
build:
go build -o tendermint github.com/tendermint/tendermint/cmd
test:
go test github.com/tendermint/tendermint/...
list_deps:
go list -f '{{join .Deps "\n"}}' github.com/tendermint/tendermint/... | xargs go list -f '{{if not .Standard}}{{.ImportPath}}{{end}}'
get_deps:
go get github.com/tendermint/tendermint/...

View File

@ -2,6 +2,7 @@ package account
import (
"errors"
"fmt"
"io"
"reflect"
@ -56,3 +57,7 @@ func (sig SignatureEd25519) ValidateBasic() error {
func (sig SignatureEd25519) IsZero() bool {
return len(sig.Bytes) == 0
}
func (sig SignatureEd25519) String() string {
return fmt.Sprintf("%X", Fingerprint(sig.Bytes))
}

View File

@ -189,13 +189,8 @@ func writeReflect(rv reflect.Value, rt reflect.Type, w io.Writer, n *int64, err
return
}
// Dereference pointer or interface
if rt.Kind() == reflect.Ptr {
rt = rt.Elem()
rv = rv.Elem()
// RegisterType registers the ptr type,
// so typeInfo is already for the ptr.
} else if rt.Kind() == reflect.Interface {
// Dereference interface
if rt.Kind() == reflect.Interface {
rv = rv.Elem()
rt = rv.Type()
typeInfo = typeInfos[rt]
@ -205,6 +200,14 @@ func writeReflect(rv reflect.Value, rt reflect.Type, w io.Writer, n *int64, err
}
}
// Dereference pointer
if rt.Kind() == reflect.Ptr {
rt = rt.Elem()
rv = rv.Elem()
// RegisterType registers the ptr type,
// so typeInfo is already for the ptr.
}
// Write TypeByte prefix
if typeInfo.HasTypeByte {
WriteByte(typeInfo.TypeByte, w, n, err)
@ -215,7 +218,7 @@ func writeReflect(rv reflect.Value, rt reflect.Type, w io.Writer, n *int64, err
elemRt := rt.Elem()
if elemRt.Kind() == reflect.Uint8 {
// Special case: Byteslices
byteslice := rv.Interface().([]byte)
byteslice := rv.Bytes()
WriteByteSlice(byteslice, w, n, err)
} else {
// Write length

View File

@ -33,6 +33,6 @@ Commands:
case "probe_upnp":
probe_upnp()
default:
fmt.Println("Unknown command %v", args[0])
fmt.Printf("Unknown command %v\n", args[0])
}
}

View File

@ -6,10 +6,6 @@ import (
var log = logging.MustGetLogger("mempool")
func init() {
logging.SetFormatter(logging.MustStringFormatter("[%{level:.1s}] %{message}"))
}
func SetMempoolLogger(l *logging.Logger) {
log = l
}

View File

@ -183,6 +183,7 @@ func (c *MConnection) Send(chId byte, msg interface{}) bool {
}
log.Debug("[%X] Send to %v: %v", chId, c, msg)
log.Debug(" Bytes: %X", BinaryBytes(msg))
// Send message to channel.
channel, ok := c.channelsIdx[chId]