diff --git a/mapblockaccessor/logger.go b/mapblockaccessor/logger.go new file mode 100644 index 0000000..237982e --- /dev/null +++ b/mapblockaccessor/logger.go @@ -0,0 +1,10 @@ +package mapblockaccessor + +import ( + "github.com/sirupsen/logrus" +) + +var log *logrus.Entry +func init(){ + log = logrus.WithFields(logrus.Fields{"prefix": "mapblockaccessor"}) +} diff --git a/mapblockaccessor/mapblockaccessor_test.go b/mapblockaccessor/mapblockaccessor_test.go index 4c734cb..2efeab8 100644 --- a/mapblockaccessor/mapblockaccessor_test.go +++ b/mapblockaccessor/mapblockaccessor_test.go @@ -7,6 +7,7 @@ import ( "mapserver/db" "os" "testing" + "github.com/sirupsen/logrus" ) func copy(src, dst string) error { @@ -55,6 +56,7 @@ func GetTestDatabase() db.DBAccessor { } func TestSimpleAccess(t *testing.T) { + logrus.SetLevel(logrus.DebugLevel) a := GetTestDatabase() cache := NewMapBlockAccessor(a) mb, err := cache.GetMapBlock(coords.NewMapBlockCoords(0, 0, 0)) diff --git a/mapblockparser/logger.go b/mapblockparser/logger.go new file mode 100644 index 0000000..f61dc6c --- /dev/null +++ b/mapblockparser/logger.go @@ -0,0 +1,10 @@ +package mapblockparser + +import ( + "github.com/sirupsen/logrus" +) + +var log *logrus.Entry +func init(){ + log = logrus.WithFields(logrus.Fields{"prefix": "mapblockaccessor"}) +} diff --git a/mapblockparser/metadata.go b/mapblockparser/metadata.go index b16bd45..870cbc8 100644 --- a/mapblockparser/metadata.go +++ b/mapblockparser/metadata.go @@ -8,6 +8,7 @@ import ( "io" "strconv" "strings" + "github.com/sirupsen/logrus" ) const ( @@ -49,9 +50,16 @@ func parseMetadata(mapblock *MapBlock, data []byte) (int, error) { metadata := buf.Bytes() + log.WithFields(logrus.Fields{"metadata-length": len(metadata)}).Debug("Parsing metadata") + offset := 0 version := metadata[offset] + if version == 0 { + //No data? + return cr.Count, nil + } + if version != 2 { return 0, errors.New("Wrong metadata version: " + strconv.Itoa(int(version))) }