remove all print statemens - use log.Debug() (or Info()) where appropriate
This commit is contained in:
parent
e063bb1b03
commit
9dc12deb19
5 changed files with 9 additions and 21 deletions
13
app/app.go
13
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)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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()
|
||||
}
|
||||
|
|
|
@ -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()
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue