refactor: replace logrus with log/slog

This commit is contained in:
rramiachraf 2024-05-02 21:29:50 +01:00
parent 56c745d6f5
commit c940b4a2cd
18 changed files with 120 additions and 70 deletions

14
main.go
View file

@ -9,11 +9,11 @@ import (
"time"
"github.com/rramiachraf/dumb/handlers"
"github.com/sirupsen/logrus"
"github.com/rramiachraf/dumb/utils"
)
func main() {
var logger = logrus.New()
logger := utils.NewLogger(os.Stdout)
server := &http.Server{
Handler: handlers.New(logger),
@ -25,14 +25,18 @@ func main() {
if port == 0 {
port = 5555
logger.Info("using default port %d", port)
}
l, err := net.Listen("tcp", fmt.Sprintf(":%d", port))
if err != nil {
logger.Fatalln(err)
logger.Error(err.Error())
}
logger.Infof("server is listening on port %d\n", port)
logger.Info("server is listening on port %d", port)
logger.Fatalln(server.Serve(l))
if err := server.Serve(l); err != nil {
logger.Error(err.Error())
os.Exit(1)
}
}