From 26cfd2a38fbb8db73c9c0db624409e4ab2d3e4b1 Mon Sep 17 00:00:00 2001 From: ycc Date: Wed, 4 Sep 2024 12:09:26 +0200 Subject: [PATCH] fix accessor init location --- entrypoint.go | 50 ++++++++++++++++++++++++++------------------------ 1 file changed, 26 insertions(+), 24 deletions(-) diff --git a/entrypoint.go b/entrypoint.go index b463ed8..6e3ed4a 100644 --- a/entrypoint.go +++ b/entrypoint.go @@ -107,6 +107,31 @@ func Init(appName string) { config.SetAppName(appName) // set the app name to the logger to define the main log chan // create a temporary console logger for init logs.SetLogger(logs.CreateLogger("main")) + +} + +// +// Expose subpackages +// + +/* GetLogger returns the main logger +* @return zerolog.Logger + */ +func GetLogger() zerolog.Logger { + return logs.GetLogger() +} + +/* SetConfig will set the config and create a logger according to app configuration and initialize mongo accessor +* @param url string +* @param database string +* @param natsUrl string +* @param lokiUrl string +* @param logLevel string +* @return *Config + */ +func SetConfig(mongoUrl string, database string, natsUrl string, lokiUrl string, logLevel string) *config.Config { + logs.CreateLogger("main") + cfg := config.SetConfig(mongoUrl, database, natsUrl, lokiUrl, logLevel) mongo.MONGOService.Init(models.GetModelsNames(), config.GetConfig()) // init the mongo service /* Here we will check if the resource model is already stored in the database @@ -144,30 +169,7 @@ func Init(appName string) { }) } } -} - -// -// Expose subpackages -// - -/* GetLogger returns the main logger -* @return zerolog.Logger - */ -func GetLogger() zerolog.Logger { - return logs.GetLogger() -} - -/* SetConfig will set the config and create a logger according to app configuration -* @param url string -* @param database string -* @param natsUrl string -* @param lokiUrl string -* @param logLevel string -* @return *Config - */ -func SetConfig(mongoUrl string, database string, natsUrl string, lokiUrl string, logLevel string) *config.Config { - logs.CreateLogger("main") - return config.SetConfig(mongoUrl, database, natsUrl, lokiUrl, logLevel) + return cfg } /* GetConfLoader