diff --git a/entrypoint.go b/entrypoint.go index 6e3ed4a..5ddd6e2 100644 --- a/entrypoint.go +++ b/entrypoint.go @@ -98,12 +98,6 @@ func AddPath(collection LibDataEnum, path 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 // create a temporary console logger for init logs.SetLogger(logs.CreateLogger("main")) @@ -130,6 +124,12 @@ func GetLogger() zerolog.Logger { * @return *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") cfg := config.SetConfig(mongoUrl, database, natsUrl, lokiUrl, logLevel) mongo.MONGOService.Init(models.GetModelsNames(), config.GetConfig()) // init the mongo service