diff --git a/cmd/echo/main.go b/cmd/echo/main.go index d453196..9dcec57 100644 --- a/cmd/echo/main.go +++ b/cmd/echo/main.go @@ -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 { diff --git a/cmd/echo/logger.go b/logger/wrappedslogger.go similarity index 98% rename from cmd/echo/logger.go rename to logger/wrappedslogger.go index 82e9399..4b14a11 100644 --- a/cmd/echo/logger.go +++ b/logger/wrappedslogger.go @@ -1,4 +1,4 @@ -package main +package logger import ( "log/slog"