fix(log): update trace error log

This commit is contained in:
Medzik 2021-11-07 19:19:06 +00:00
parent 55b4fb0b14
commit a880aaf054
4 changed files with 15 additions and 5 deletions

View File

@ -20,14 +20,18 @@ func Connect() error {
defer cancel()
Client, err := mongo.Connect(ctx, options.Client().ApplyURI(config.Mongo_URI))
if common.CheckErr(err, "connect to db") {
if err != nil {
common.Log.Error("connect to db", err)
time.Sleep(2 * time.Second)
return err
}
err = Client.Ping(ctx, readpref.Primary())
if common.CheckErr(err, "ping db") {
if err != nil {
common.Log.Error("ping db", err)
time.Sleep(2 * time.Second)
return err

View File

@ -25,7 +25,9 @@ func loop(url string) {
defer cancel()
req, err := http.NewRequestWithContext(ctx, "GET", url, nil)
if common.CheckErr(err, "new http request") {
if err != nil {
common.Log.Error("new http request", err)
Status.Error++
return

View File

@ -17,7 +17,9 @@ func Status(c *gin.Context) {
mem := stats.Memory()
cpu, err := stats.CPU()
common.CheckErr(err, "cpu stat")
if err != nil {
common.Log.Error("cpu stat", err)
}
var p json

View File

@ -31,7 +31,9 @@ func Server() {
api.ApplyRoutes(router)
err := router.Run(":" + strconv.Itoa(config.Toml.HTTP.Port))
if common.CheckErr(err, "gin server run") {
if err != nil {
common.Log.Error("gin start http server", err)
os.Exit(1)
}
}