aboutsummaryrefslogtreecommitdiff
path: root/caronte.go
diff options
context:
space:
mode:
authorVaiTon2023-11-25 12:40:44 +0000
committerVaiTon2023-11-25 12:40:44 +0000
commit2beddfc17cf736844cffe6a94bf647afc4796423 (patch)
tree3601fa303a748e4a98896eb13497476e9a1626a1 /caronte.go
parent18df9f897cddb57720296437b7da065e1430c6ef (diff)
Use zerolog in caronte.go and print more debug info
Diffstat (limited to 'caronte.go')
-rw-r--r--caronte.go32
1 files changed, 25 insertions, 7 deletions
diff --git a/caronte.go b/caronte.go
index 039694c..456eb68 100644
--- a/caronte.go
+++ b/caronte.go
@@ -20,8 +20,10 @@ package main
import (
"flag"
"fmt"
+ "os"
- log "github.com/sirupsen/logrus"
+ "github.com/rs/zerolog"
+ log "github.com/rs/zerolog/log"
)
var Version string
@@ -36,33 +38,49 @@ var (
func main() {
+ log.Logger = log.Output(zerolog.ConsoleWriter{Out: os.Stderr})
+
flag.Parse()
- logFields := log.Fields{"host": *mongoHost, "port": *mongoPort, "dbName": *dbName}
- log.WithFields(logFields).Debug("connecting to MongoDB")
+ log.Debug().Msg("starting caronte")
+
+ log.Debug().Str("host", *mongoHost).Int("port", *mongoPort).Str("dbName", *dbName).
+ Msg("connecting to MongoDB")
storage, err := NewMongoStorage(*mongoHost, *mongoPort, *dbName)
if err != nil {
- log.WithError(err).WithFields(logFields).Fatal("failed to connect to MongoDB")
+ log.Fatal().Err(err).Msg("failed to connect to MongoDB")
}
if Version == "" {
Version = "undefined"
}
+
+ log.Debug().Msg("creating application context")
applicationContext, err := CreateApplicationContext(storage, Version)
if err != nil {
- log.WithError(err).WithFields(logFields).Fatal("failed to create application context")
+ log.Fatal().Err(err).Msg("failed to create application context")
}
+ log.Debug().Msg("application context created")
+ log.Debug().Msg("creating notification controller")
notificationController := NewNotificationController(applicationContext)
go notificationController.Run()
applicationContext.SetNotificationController(notificationController)
+ log.Debug().Msg("notification controller created")
+ log.Debug().Msg("creating resources controller")
resourcesController := NewResourcesController(notificationController)
go resourcesController.Run()
+ log.Debug().Msg("resources controller created")
+ log.Debug().Msg("creating application router")
applicationContext.Configure()
applicationRouter := CreateApplicationRouter(applicationContext, notificationController, resourcesController)
- if applicationRouter.Run(fmt.Sprintf("%s:%v", *bindAddress, *bindPort)) != nil {
- log.WithError(err).WithFields(logFields).Fatal("failed to create the server")
+ log.Debug().Msg("application router created")
+
+ log.Debug().Msg("starting server")
+ err = applicationRouter.Run(fmt.Sprintf("%s:%v", *bindAddress, *bindPort))
+ if err != nil {
+ log.Fatal().Err(err).Msg("failed to create the server")
}
}