fix logging

This commit is contained in:
Thomas Rudin 2019-01-09 08:56:39 +01:00
parent 3b005e8958
commit 185dff60bc
6 changed files with 10 additions and 36 deletions

View File

@ -5,6 +5,7 @@ import (
"mapserver/worldconfig"
"flag"
"fmt"
"github.com/sirupsen/logrus"
)
const (
@ -26,5 +27,7 @@ func main() {
}
worldcfg := worldconfig.Parse(p.Worlddir + "world.mt")
logrus.WithFields(logrus.Fields{"version":Version}).Info("Starting mapserver")
fmt.Println("Config ", worldcfg)
}

View File

@ -6,17 +6,11 @@ import (
"errors"
"io"
"strconv"
log "github.com/sirupsen/logrus"
)
//TODO: mapdata struct with accessors
func parseMapdata(mapblock *MapBlock, data []byte) (int, error) {
log.WithFields(log.Fields{
"data-length": len(data),
}).Debug("Parsing map-data")
r := bytes.NewReader(data)
cr := new(CountedReader)

View File

@ -8,8 +8,6 @@ import (
"io"
"strconv"
"strings"
log "github.com/sirupsen/logrus"
)
const (
@ -30,10 +28,6 @@ func readU32(data []byte, offset int) int {
}
func parseMetadata(mapblock *MapBlock, data []byte) (int, error) {
log.WithFields(log.Fields{
"data-length": len(data),
}).Debug("Parsing metadata")
r := bytes.NewReader(data)
cr := new(CountedReader)
@ -65,11 +59,6 @@ func parseMetadata(mapblock *MapBlock, data []byte) (int, error) {
offset++
count := readU16(metadata, offset)
log.WithFields(log.Fields{
"count": count,
"version": version,
}).Debug("Parsed metadata-header")
offset += 2
for i := 0; i < count; i++ {

View File

@ -3,8 +3,6 @@ package mapblockparser
import (
"errors"
"strconv"
log "github.com/sirupsen/logrus"
)
func Parse(data []byte) (*MapBlock, error) {
@ -13,10 +11,6 @@ func Parse(data []byte) (*MapBlock, error) {
return nil, errors.New("no data")
}
log.WithFields(log.Fields{
"data-length": len(data),
}).Debug("Parsing mapblock")
offset := 0
// version

View File

@ -5,8 +5,6 @@ import (
"io/ioutil"
"strconv"
"testing"
log "github.com/sirupsen/logrus"
)
func TestReadU16(t *testing.T) {
@ -34,7 +32,6 @@ func TestReadU32(t *testing.T) {
}
func TestParse(t *testing.T) {
log.SetLevel(log.DebugLevel)
data, err := ioutil.ReadFile("testdata/0.0.0")
if err != nil {
@ -66,7 +63,6 @@ func TestParse(t *testing.T) {
}
func TestParse2(t *testing.T) {
log.SetLevel(log.DebugLevel)
data, err := ioutil.ReadFile("testdata/11.0.2")
if err != nil {
@ -85,7 +81,6 @@ func TestParse2(t *testing.T) {
}
func TestParse3(t *testing.T) {
log.SetLevel(log.DebugLevel)
data, err := ioutil.ReadFile("testdata/0.1.0")
if err != nil {

View File

@ -1,29 +1,28 @@
package worldconfig_test
package worldconfig
import (
"testing"
"fmt"
worldconfig "mapserver/worldconfig"
)
func TestParseSqlite(t *testing.T) {
cfg := worldconfig.Parse("./testdata/world.mt.sqlite")
if cfg.Backend != worldconfig.BACKEND_SQLITE3 {
cfg := Parse("./testdata/world.mt.sqlite")
if cfg.Backend != BACKEND_SQLITE3 {
t.Fatal("not sqlite3")
}
if cfg.PlayerBackend != worldconfig.BACKEND_FILES {
if cfg.PlayerBackend != BACKEND_FILES {
t.Fatal("not files")
}
}
func TestParsePostgres(t *testing.T) {
cfg := worldconfig.Parse("./testdata/world.mt.postgres")
cfg := Parse("./testdata/world.mt.postgres")
fmt.Println(cfg)
if cfg.Backend != worldconfig.BACKEND_POSTGRES {
if cfg.Backend != BACKEND_POSTGRES {
t.Fatal("not postgres")
}
if cfg.PlayerBackend != worldconfig.BACKEND_POSTGRES {
if cfg.PlayerBackend != BACKEND_POSTGRES {
t.Fatal("not postgres")
}