diff --git a/app/app.go b/app/app.go index c072afe..0c29787 100644 --- a/app/app.go +++ b/app/app.go @@ -1,7 +1,6 @@ package app import ( - "fmt" "os" "os/signal" "syscall" @@ -29,10 +28,8 @@ func start(ctx lib.Context) { for _, cfg := range ctx.Config().Children() { cctx := ctx.ChildContext(cfg) cfg.Starter()(cctx) - fmt.Println(cfg.Name(), " started") - log.Info().Str("service", cfg.Name()).Msg("started") } - fmt.Println("running ", ctx.WaitGroup()) + log.Info().Msg("app.start: running") sig := make(chan os.Signal, 1) signal.Notify(sig, syscall.SIGINT, syscall.SIGTERM) for step(ctx, sig) { @@ -42,14 +39,12 @@ func start(ctx lib.Context) { func step(ctx lib.Context, sig <-chan os.Signal) bool { select { case <-sig: - fmt.Println("interrupted") - //ctx.LogInfo("Dispatcher interrupted", m.Map{}) + log.Info().Msg("app.step: interrupted") return false case msg := <-ctx.Mailbox(): - fmt.Println("app.step: message =", msg) - //ctx.LogDebug("dispatcherStep", m.Map{"msg": msg}) + //log.Debug().Str("msg.action", msg.Action()).Msg("app.step: message") if msg == message.Quit { - //ctx.LogInfo("Dispatcher stopped", m.Map{}) + log.Info().Msg("app.step: stopped") return false } return lib.HandleMsg(ctx, msg) diff --git a/lib/action/action.go b/lib/action/action.go index ee27d20..6b2cfaa 100644 --- a/lib/action/action.go +++ b/lib/action/action.go @@ -1,8 +1,6 @@ package action import ( - "fmt" - "git.sr.ht/~cco/go-scopes/lib" "git.sr.ht/~cco/go-scopes/lib/message" "git.sr.ht/~cco/go-scopes/logging/log" @@ -43,8 +41,7 @@ func Select(ctx lib.Context, msg lib.Message) []lib.Action { } func match(ac lib.ActionConfig, msg lib.Message) bool { - fmt.Println("action.match", ac.Pattern(), msg.Action()) - log.Debug().Str("pattern", ac.Pattern()).Str("action", msg.Action()). + log.Debug().Str("pattern", ac.Pattern()).Str("msg.action", msg.Action()). Msg("action.match") return ac.Pattern() == msg.Action() //return false diff --git a/lib/core/core.go b/lib/core/core.go index 4dcbbab..b0d7941 100644 --- a/lib/core/core.go +++ b/lib/core/core.go @@ -1,15 +1,14 @@ package core import ( - "fmt" - "git.sr.ht/~cco/go-scopes/config" "git.sr.ht/~cco/go-scopes/lib" "git.sr.ht/~cco/go-scopes/lib/action" + "git.sr.ht/~cco/go-scopes/logging/log" ) func Start(ctx lib.Context) { - fmt.Println("Start:", ctx.Config().Name()) + log.Debug().Str("service", ctx.Config().Name()).Msg("core.Start") lib.RunCtx(ctx, Listen) } @@ -33,7 +32,8 @@ func Step(ctx lib.Context) (loop bool) { func HandleMessage(ctx lib.Context, msg lib.Message) (loop bool) { loop = true - fmt.Println("core.HandleMessage", ctx.Config().Name(), msg) + log.Debug().Str("service", ctx.Config().Name()).Str("msg.action", msg.Action()). + Msg("core.HandleMessage") for _, act := range action.Select(ctx, msg) { loop = act.Handle() } diff --git a/testing/testing.go b/testing/testing.go index b209d75..1d55436 100644 --- a/testing/testing.go +++ b/testing/testing.go @@ -3,7 +3,6 @@ package testing import ( - "fmt" "regexp" "testing" "time" @@ -54,7 +53,6 @@ func (t *T) TearDownApp() { time.Sleep(100 * time.Millisecond) //t.Check() message.SimpleAddress("testing").Send(t.Ctx, message.Quit) - fmt.Println("teardown ", t.Ctx.WaitGroup()) t.Ctx.WaitGroup().Wait() //t.AssertNoUncheckedMessages() } diff --git a/tests/scopes_test.go b/tests/scopes_test.go index a8dbc4a..127670b 100644 --- a/tests/scopes_test.go +++ b/tests/scopes_test.go @@ -1,7 +1,6 @@ package scopes_test import ( - "fmt" "os" tbase "testing" @@ -47,7 +46,6 @@ func SendTest(t *testing.T) { func Receiver(act lib.Action) bool { // t := testing.GetT(act.Context()) t := act.Context().Parent().State().(*testing.T) - fmt.Println("test.Receiver:", act.Message().Action()) t.AssertEqual(act.Message().Action(), "demo") return true }