forked from MTSR/mapserver
logging & fixes
This commit is contained in:
parent
18fb3240d5
commit
8256a47851
11
server/mapobject/logger.go
Normal file
11
server/mapobject/logger.go
Normal file
@ -0,0 +1,11 @@
|
||||
package mapobject
|
||||
|
||||
import (
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
var log *logrus.Entry
|
||||
|
||||
func init() {
|
||||
log = logrus.WithFields(logrus.Fields{"prefix": "mapobject"})
|
||||
}
|
@ -5,6 +5,8 @@ import (
|
||||
"mapserver/eventbus"
|
||||
"mapserver/mapblockparser"
|
||||
"mapserver/mapobjectdb"
|
||||
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
type MapObjectListener interface {
|
||||
@ -44,6 +46,16 @@ func (this *Listener) OnEvent(eventtype string, o interface{}) {
|
||||
for z := 0; z < 16; z++ {
|
||||
nodeid := block.GetNodeId(x, y, z)
|
||||
if nodeid == id {
|
||||
fields := logrus.Fields{
|
||||
"mbpos": block.Pos,
|
||||
"x": x,
|
||||
"y": y,
|
||||
"z": z,
|
||||
"type": name,
|
||||
"nodeid": nodeid,
|
||||
}
|
||||
log.WithFields(fields).Debug("OnEvent()")
|
||||
|
||||
obj := v.onMapObject(x, y, z, block)
|
||||
|
||||
if obj != nil {
|
||||
|
@ -3,6 +3,8 @@ package mapobjectdb
|
||||
import (
|
||||
"mapserver/coords"
|
||||
"time"
|
||||
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
/*
|
||||
@ -33,9 +35,14 @@ type MapObject struct {
|
||||
|
||||
func NewMapObject(MBPos *coords.MapBlockCoords, x int, y int, z int, _type string) *MapObject {
|
||||
|
||||
if x > 16 || y > 16 || z > 16 {
|
||||
panic("Out of range3!") //XXX
|
||||
fields := logrus.Fields{
|
||||
"mbpos": MBPos,
|
||||
"x": x,
|
||||
"y": y,
|
||||
"z": z,
|
||||
"type": _type,
|
||||
}
|
||||
log.WithFields(fields).Debug("NewMapObject")
|
||||
|
||||
o := MapObject{
|
||||
MBPos: MBPos,
|
||||
|
11
server/mapobjectdb/logger.go
Normal file
11
server/mapobjectdb/logger.go
Normal file
@ -0,0 +1,11 @@
|
||||
package mapobjectdb
|
||||
|
||||
import (
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
var log *logrus.Entry
|
||||
|
||||
func init() {
|
||||
log = logrus.WithFields(logrus.Fields{"prefix": "mapobjectdb"})
|
||||
}
|
@ -5,7 +5,6 @@ import (
|
||||
"mapserver/mapobjectdb"
|
||||
)
|
||||
|
||||
|
||||
func (db *Sqlite3Accessor) GetMapData(q mapobjectdb.SearchQuery) ([]*mapobjectdb.MapObject, error) {
|
||||
rows, err := db.db.Query(getMapDataPosQuery,
|
||||
q.Type,
|
||||
@ -42,11 +41,15 @@ func (db *Sqlite3Accessor) GetMapData(q mapobjectdb.SearchQuery) ([]*mapobjectdb
|
||||
|
||||
if currentId == nil || *currentId != id {
|
||||
pos := coords.NewMapBlockCoords(posx, posy, posz)
|
||||
mo := mapobjectdb.NewMapObject(
|
||||
pos,
|
||||
x, y, z,
|
||||
Type,
|
||||
)
|
||||
mo := &mapobjectdb.MapObject{
|
||||
MBPos: pos,
|
||||
Type: Type,
|
||||
X: x,
|
||||
Y: y,
|
||||
Z: z,
|
||||
Mtime: mtime,
|
||||
Attributes: make(map[string]string),
|
||||
}
|
||||
|
||||
currentObj = mo
|
||||
currentId = &id
|
||||
@ -66,7 +69,6 @@ func (db *Sqlite3Accessor) RemoveMapData(pos *coords.MapBlockCoords) error {
|
||||
return err
|
||||
}
|
||||
|
||||
|
||||
func (db *Sqlite3Accessor) AddMapData(data *mapobjectdb.MapObject) error {
|
||||
res, err := db.db.Exec(addMapDataQuery,
|
||||
data.X, data.Y, data.Z,
|
||||
|
Loading…
Reference in New Issue
Block a user