From bc9e2eced977a46541391a22c2f203f2fde6e61a Mon Sep 17 00:00:00 2001 From: Max Date: Wed, 9 Feb 2022 23:15:02 +0800 Subject: [PATCH] fix session logger bug --- share/session.go | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/share/session.go b/share/session.go index 4e5049adc2..719bf4dd88 100644 --- a/share/session.go +++ b/share/session.go @@ -3,9 +3,11 @@ package share import ( "context" "fmt" - "io/ioutil" + "io" "log" + klog "github.com/yaoapp/kun/log" + "github.com/buraksezer/olric" "github.com/buraksezer/olric/client" config_olric "github.com/buraksezer/olric/config" @@ -55,6 +57,7 @@ func SessionServerStart() { Peers: []string{}, DMaps: &config_olric.DMaps{}, StorageEngines: config_olric.NewStorageEngine(), + Logger: &log.Logger{}, } m, err := config_olric.NewMemberlistConfig("local") @@ -73,30 +76,30 @@ func SessionServerStart() { // c.BindAddr = config.Conf.Session.Host // c.BindPort = config.Conf.Session.Port - c.Logger.SetOutput(ioutil.Discard) // 暂时关闭日志 + c.Logger.SetOutput(io.Discard) // 暂时关闭日志 ctx, cancel := context.WithCancel(context.Background()) c.Started = func() { defer cancel() - log.Println("[INFO] Olric is ready to accept connections") + klog.Trace("[INFO] Olric is ready to accept connections") } sessServer, err = olric.New(c) if err != nil { - log.Fatalf("Failed to create Olric instance: %v", err) + klog.Error("Failed to create Olric instance: %v", err) } go func() { err = sessServer.Start() // Call Start at background. It's a blocker call. if err != nil { - log.Fatalf("olric.Start returned an error: %v", err) + klog.Panic("olric.Start returned an error: %v", err) } }() <-ctx.Done() dm, err := sessServer.NewDMap("local-session") if err != nil { - log.Fatalf("olric.NewDMap returned an error: %v", err) + klog.Panic("olric.NewDMap returned an error: %v", err) } session.MemoryUse(session.ServerDMap{DMap: dm})