mirror of
https://git.rwth-aachen.de/acs/public/villas/web-backend-go/
synced 2025-03-30 00:00:12 +01:00
use log package
This commit is contained in:
parent
1c9986337e
commit
81b0110b68
3 changed files with 11 additions and 6 deletions
|
@ -1,8 +1,9 @@
|
|||
package database
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"log"
|
||||
|
||||
"github.com/jinzhu/gorm"
|
||||
_ "github.com/jinzhu/gorm/dialects/postgres"
|
||||
"log"
|
||||
|
@ -54,6 +55,8 @@ func InitDB(dbname string, isTest bool) *gorm.DB {
|
|||
DropTables(db)
|
||||
}
|
||||
|
||||
log.Println("Database connection established")
|
||||
|
||||
return db
|
||||
}
|
||||
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
package healthz
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"git.rwth-aachen.de/acs/public/villas/web-backend-go/amqp"
|
||||
"git.rwth-aachen.de/acs/public/villas/web-backend-go/database"
|
||||
"github.com/gin-gonic/gin"
|
||||
"log"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
|
@ -35,7 +35,7 @@ func getHealth(c *gin.Context) {
|
|||
if len(database.AMQP_URL) != 0 {
|
||||
err = amqp.CheckConnection()
|
||||
if err != nil {
|
||||
fmt.Println(err.Error())
|
||||
log.Println(err.Error())
|
||||
c.JSON(http.StatusInternalServerError, gin.H{
|
||||
"success:": false,
|
||||
"message": err.Error(),
|
||||
|
|
8
start.go
8
start.go
|
@ -1,7 +1,7 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"git.rwth-aachen.de/acs/public/villas/web-backend-go/amqp"
|
||||
"git.rwth-aachen.de/acs/public/villas/web-backend-go/routes/healthz"
|
||||
"time"
|
||||
|
@ -71,7 +71,7 @@ func main() {
|
|||
fmt.Println("Starting AMQP client")
|
||||
err := amqp.ConnectAMQP(database.AMQP_URL)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
log.Panic(err)
|
||||
}
|
||||
|
||||
// Periodically call the Ping function to check which simulators are still there
|
||||
|
@ -83,12 +83,14 @@ func main() {
|
|||
case <-ticker.C:
|
||||
err = amqp.PingAMQP()
|
||||
if err != nil {
|
||||
fmt.Println("AMQP Error: ", err.Error())
|
||||
log.Println("AMQP Error: ", err.Error())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}()
|
||||
|
||||
log.Printf("Connected AMQP client to %s", amqpurl)
|
||||
}
|
||||
// server at port 4000 to match frontend's redirect path
|
||||
r.Run(":4000")
|
||||
|
|
Loading…
Add table
Reference in a new issue