From 7d83bde5e960061d5dd9a2c7f7919804dee02f35 Mon Sep 17 00:00:00 2001 From: BuckarooBanzay Date: Thu, 16 Feb 2023 11:15:41 +0100 Subject: [PATCH] add logrus --- context.go | 11 +++++++++++ go.mod | 1 + go.sum | 4 ++++ 3 files changed, 16 insertions(+) diff --git a/context.go b/context.go index dbf0581..a11829f 100644 --- a/context.go +++ b/context.go @@ -12,6 +12,7 @@ import ( "github.com/minetest-go/mtdb/types" "github.com/minetest-go/mtdb/wal" "github.com/minetest-go/mtdb/worldconfig" + "github.com/sirupsen/logrus" _ "modernc.org/sqlite" ) @@ -40,6 +41,12 @@ func connectAndMigrate(t types.DatabaseType, sqliteConn, psqlConn string, migFn var datasource string var dbtype string + logrus.WithFields(logrus.Fields{ + "db_type": t, + "sqlite_conn": sqliteConn, + "pg_conn": psqlConn, + }).Debug("Connecting and migrating") + switch t { case types.DATABASE_DUMMY: return nil, nil @@ -80,6 +87,8 @@ func connectAndMigrate(t types.DatabaseType, sqliteConn, psqlConn string, migFn // parses the "world.mt" file in the world-dir and creates a new context func New(world_dir string) (*Context, error) { + + logrus.WithFields(logrus.Fields{"world_dir": world_dir}).Debug("Creating new DB context") wc, err := worldconfig.Parse(path.Join(world_dir, "world.mt")) if err != nil { return nil, err @@ -152,6 +161,8 @@ func New(world_dir string) (*Context, error) { } func NewBlockDB(world_dir string) (block.BlockRepository, error) { + logrus.WithFields(logrus.Fields{"world_dir": world_dir}).Debug("Creating new Block-DB") + wc, err := worldconfig.Parse(path.Join(world_dir, "world.mt")) if err != nil { return nil, err diff --git a/go.mod b/go.mod index 320fd5b..72e8da8 100644 --- a/go.mod +++ b/go.mod @@ -17,6 +17,7 @@ require ( github.com/lib/pq v1.10.7 github.com/mattn/go-isatty v0.0.16 // indirect github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0 // indirect + github.com/sirupsen/logrus v1.9.0 github.com/stretchr/testify v1.8.1 golang.org/x/mod v0.6.0-dev.0.20220106191415-9b9b3d81d5e3 // indirect golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab // indirect diff --git a/go.sum b/go.sum index 9283637..5afa7cd 100644 --- a/go.sum +++ b/go.sum @@ -24,9 +24,12 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0 h1:OdAsTTz6OkFY5QxjkYwrChwuRruF69c169dPK26NUlk= github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo= +github.com/sirupsen/logrus v1.9.0 h1:trlNQbNUG3OdDrDil03MCb1H2o9nJ1x4/5LYw7byDE0= +github.com/sirupsen/logrus v1.9.0/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= +github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= @@ -52,6 +55,7 @@ golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20211007075335-d3039528d8ac/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220503163025-988cb79eb6c6 h1:nonptSpoQ4vQjyraW20DXPAglgQfVnM9ZC6MmNLMR60= golang.org/x/sys v0.0.0-20220503163025-988cb79eb6c6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab h1:2QkjZIsXupsJbJIdSjjUOgWK3aEtzyuh2mPt3l/CkeU= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=