fix accessor init location

This commit is contained in:
ycc 2024-09-04 12:09:26 +02:00
parent bb36ac0fb4
commit 26cfd2a38f

View File

@ -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