1
0
forked from MTSR/mapserver

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

View File

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

View File

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

View File

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

View File

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

View File

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