fix moving recover

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

View File

@ -98,12 +98,6 @@ func AddPath(collection LibDataEnum, path string) {
} }
func Init(appName string) { func Init(appName string) {
defer func() {
if r := recover(); r != nil {
tools.UncatchedError = append(tools.UncatchedError, errors.New("Panic recovered in Init : "+fmt.Sprintf("%v", r)+" - "+string(debug.Stack())))
fmt.Printf("Panic recovered in Init : %v - %v\n", r, string(debug.Stack()))
}
}()
config.SetAppName(appName) // set the app name to the logger to define the main log chan config.SetAppName(appName) // set the app name to the logger to define the main log chan
// create a temporary console logger for init // create a temporary console logger for init
logs.SetLogger(logs.CreateLogger("main")) logs.SetLogger(logs.CreateLogger("main"))
@ -130,6 +124,12 @@ func GetLogger() zerolog.Logger {
* @return *Config * @return *Config
*/ */
func SetConfig(mongoUrl string, database string, natsUrl string, lokiUrl string, logLevel string) *config.Config { func SetConfig(mongoUrl string, database string, natsUrl string, lokiUrl string, logLevel string) *config.Config {
defer func() {
if r := recover(); r != nil {
tools.UncatchedError = append(tools.UncatchedError, errors.New("Panic recovered in Init : "+fmt.Sprintf("%v", r)+" - "+string(debug.Stack())))
fmt.Printf("Panic recovered in Init : %v - %v\n", r, string(debug.Stack()))
}
}()
logs.CreateLogger("main") logs.CreateLogger("main")
cfg := config.SetConfig(mongoUrl, database, natsUrl, lokiUrl, logLevel) cfg := config.SetConfig(mongoUrl, database, natsUrl, lokiUrl, logLevel)
mongo.MONGOService.Init(models.GetModelsNames(), config.GetConfig()) // init the mongo service mongo.MONGOService.Init(models.GetModelsNames(), config.GetConfig()) // init the mongo service