Browse Source

Better debug output

pull/9/head
Jae Kwon 10 years ago
parent
commit
b0755c938a
6 changed files with 31 additions and 13 deletions
  1. +13
    -0
      Makefile
  2. +5
    -0
      account/signature.go
  3. +11
    -8
      binary/reflect.go
  4. +1
    -1
      cmd/main.go
  5. +0
    -4
      mempool/log.go
  6. +1
    -0
      p2p/connection.go

+ 13
- 0
Makefile 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/...

+ 5
- 0
account/signature.go 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))
}

+ 11
- 8
binary/reflect.go 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


+ 1
- 1
cmd/main.go 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])
}
}

+ 0
- 4
mempool/log.go 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
}

+ 1
- 0
p2p/connection.go 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]


Loading…
Cancel
Save