fix logging for unit tests
This commit is contained in:
parent
e072e493a1
commit
235ba65c64
4 changed files with 8 additions and 3 deletions
|
@ -40,6 +40,7 @@ func Select(ctx lib.Context, msg lib.Message) []lib.Action {
|
|||
}
|
||||
}
|
||||
}
|
||||
// if len(acts) == 0 { logging.Warn().... }
|
||||
return acts
|
||||
}
|
||||
|
||||
|
|
|
@ -7,6 +7,8 @@ import (
|
|||
"git.sr.ht/~cco/go-scopes/logging"
|
||||
)
|
||||
|
||||
func NoOp(_ lib.Context) {}
|
||||
|
||||
func Start(ctx lib.Context) {
|
||||
logging.Debug(ctx).Msg("core.Start")
|
||||
lib.RunCtx(ctx, Listen)
|
||||
|
|
|
@ -28,7 +28,7 @@ var Levels = map[string]zerolog.Level{
|
|||
|
||||
type Logger = zerolog.Logger
|
||||
|
||||
var defaultLogger = log.Logger
|
||||
var defaultLogger = log.Logger.Level(InfoLevel)
|
||||
var globalLogger *Logger = &log.Logger
|
||||
|
||||
type Cfg struct {
|
||||
|
@ -38,7 +38,8 @@ type Cfg struct {
|
|||
}
|
||||
|
||||
func SetDefault() {
|
||||
globalLogger = &defaultLogger
|
||||
logger := defaultLogger
|
||||
globalLogger = &logger
|
||||
}
|
||||
|
||||
func Setup(ctx lib.Context, cfg *Cfg, home string) {
|
||||
|
|
|
@ -8,6 +8,7 @@ import (
|
|||
"git.sr.ht/~cco/go-scopes/lib"
|
||||
"git.sr.ht/~cco/go-scopes/lib/action"
|
||||
"git.sr.ht/~cco/go-scopes/lib/context"
|
||||
"git.sr.ht/~cco/go-scopes/lib/core"
|
||||
"git.sr.ht/~cco/go-scopes/lib/message"
|
||||
"git.sr.ht/~cco/go-scopes/testing"
|
||||
)
|
||||
|
@ -70,7 +71,7 @@ func ActionTest(t *testing.T) {
|
|||
return true
|
||||
}
|
||||
}
|
||||
cfg := config.Base("testing", nil).
|
||||
cfg := config.Base("testing", core.NoOp).
|
||||
AddAction("start", action.Base(hdlrGen("started"))).
|
||||
AddAction("scopes|doit|task", action.Base(hdlrGen("done")))
|
||||
ctx := context.AppContext(cfg)
|
||||
|
|
Loading…
Add table
Reference in a new issue