logging extracted

main
Nick Dumas 1 year ago
parent b47d94d1c0
commit 475f023379

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

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