logging extracted

main
Nick Dumas 1 year ago
parent b47d94d1c0
commit 475f023379

@ -2,6 +2,7 @@ package main
import ( import (
"context" "context"
"fmt"
"log" "log"
"net" "net"
@ -11,19 +12,24 @@ import (
"github.com/ThreeDotsLabs/watermill/message/router/plugin" "github.com/ThreeDotsLabs/watermill/message/router/plugin"
"github.com/ThreeDotsLabs/watermill/pubsub/gochannel" "github.com/ThreeDotsLabs/watermill/pubsub/gochannel"
"code.ndumas.com/ndumas/gomud/logger"
"code.ndumas.com/ndumas/gomud/telnet" "code.ndumas.com/ndumas/gomud/telnet"
) )
var (
port int
)
func main() { func main() {
l, err := net.Listen("tcp", ":5555") l, err := net.Listen("tcp", fmt.Sprintf(":%d", port))
if err != nil { if err != nil {
log.Fatal(err) log.Fatalf("error binding to port %d\n: %s", port, err)
} }
defer l.Close() defer l.Close()
wmLogger := watermill.NewStdLogger(false, false) wmLogger := watermill.NewStdLogger(false, false)
logger := NewWrappedSlogger() wrappedSlogger := logger.NewWrappedSlogger()
router, err := message.NewRouter(message.RouterConfig{}, logger) router, err := message.NewRouter(message.RouterConfig{}, wrappedSlogger)
router.AddPlugin(plugin.SignalsHandler) router.AddPlugin(plugin.SignalsHandler)
@ -35,8 +41,8 @@ func main() {
pubSub := gochannel.NewGoChannel(gochannel.Config{}, wmLogger) pubSub := gochannel.NewGoChannel(gochannel.Config{}, wmLogger)
ctx := context.Background() ctx := context.Background()
ts := telnet.NewTELNETServer(ctx, l, pubSub, logger) ts := telnet.NewTELNETServer(ctx, l, pubSub, wrappedSlogger)
tp := telnet.NewTELNETParser(ctx, pubSub, logger) tp := telnet.NewTELNETParser(ctx, pubSub, wrappedSlogger)
go tp.Handle() go tp.Handle()
for { for {

@ -1,4 +1,4 @@
package main package logger
import ( import (
"log/slog" "log/slog"
Loading…
Cancel
Save