mirror of
https://github.com/tobiasehlert/teslamateapi.git
synced 2026-02-27 09:54:18 +08:00
using c.Request.RequestURI in logstring
This commit is contained in:
@@ -318,17 +318,17 @@ func TeslaMateAPICarsChargesDetailsV1(c *gin.Context) {
|
||||
|
||||
// print to log about request
|
||||
if gin.IsDebugging() {
|
||||
log.Printf("[debug] TeslaMateAPICarsChargesDetailsV1 returned /api/v1/cars/%d/charges/%d data:", CarID, ChargeID)
|
||||
log.Println("[debug] TeslaMateAPICarsChargesDetailsV1 " + c.Request.RequestURI + " returned data:")
|
||||
js, _ := json.Marshal(jsonData)
|
||||
log.Printf("[debug] %s\n", js)
|
||||
}
|
||||
|
||||
// return jsonData
|
||||
if ValidResponse {
|
||||
log.Printf("[info] TeslaMateAPICarsChargesDetailsV1 executed /api/v1/cars/%d/charges/%d successful.", CarID, ChargeID)
|
||||
log.Println("[info] TeslaMateAPICarsChargesDetailsV1 " + c.Request.RequestURI + " executed successful.")
|
||||
c.JSON(http.StatusOK, jsonData)
|
||||
} else {
|
||||
log.Printf("[error] TeslaMateAPICarsChargesDetailsV1 error in /api/v1/cars/%d/charges/%d execution!", CarID, ChargeID)
|
||||
log.Println("[error] TeslaMateAPICarsChargesDetailsV1 " + c.Request.RequestURI + " error in execution!")
|
||||
c.JSON(http.StatusNotFound, gin.H{"error": "something went wrong in TeslaMateAPICarsChargesDetailsV1.."})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -178,31 +178,17 @@ func TeslaMateAPICarsV1(c *gin.Context) {
|
||||
|
||||
// print to log about request
|
||||
if gin.IsDebugging() && ValidResponse {
|
||||
if CarID > 0 {
|
||||
log.Printf("[debug] TeslaMateAPICarsV1 returned /api/v1/cars/%d data:", CarID)
|
||||
} else {
|
||||
log.Println("[debug] TeslaMateAPICarsV1 returned /api/v1/cars data:")
|
||||
}
|
||||
log.Println("[debug] TeslaMateAPICarsV1 " + c.Request.RequestURI + " returned data:")
|
||||
js, _ := json.Marshal(jsonData)
|
||||
log.Printf("[debug] %s\n", js)
|
||||
}
|
||||
|
||||
// return jsonData
|
||||
if ValidResponse {
|
||||
if CarID > 0 {
|
||||
log.Printf("[info] TeslaMateAPICarsV1 executed /api/v1/cars/%d successful.", CarID)
|
||||
} else {
|
||||
log.Println("[info] TeslaMateAPICarsV1 executed /api/v1/cars successful.")
|
||||
}
|
||||
log.Println("[info] TeslaMateAPICarsV1 " + c.Request.RequestURI + " executed successful.")
|
||||
c.JSON(http.StatusOK, jsonData)
|
||||
} else {
|
||||
if CarID > 0 {
|
||||
log.Printf("[error] TeslaMateAPICarsV1 error in /api/v1/cars/%d execution!", CarID)
|
||||
} else if len(ParamCarID) > 0 {
|
||||
log.Printf("[error] TeslaMateAPICarsV1 error in /api/v1/cars/%s execution!", ParamCarID)
|
||||
} else {
|
||||
log.Println("[error] TeslaMateAPICarsV1 error in /api/v1/cars execution!")
|
||||
}
|
||||
log.Println("[error] TeslaMateAPICarsV1 " + c.Request.RequestURI + " error in execution!")
|
||||
c.JSON(http.StatusNotFound, gin.H{"error": "something went wrong in TeslaMateAPICarsV1.."})
|
||||
}
|
||||
|
||||
|
||||
@@ -198,17 +198,17 @@ func TeslaMateAPICarsChargesV1(c *gin.Context) {
|
||||
|
||||
// print to log about request
|
||||
if gin.IsDebugging() {
|
||||
log.Printf("[debug] TeslaMateAPICarsChargesV1 returned /api/v1/cars/%d/charges data:", CarID)
|
||||
log.Println("[debug] TeslaMateAPICarsChargesV1 " + c.Request.RequestURI + " returned data:")
|
||||
js, _ := json.Marshal(jsonData)
|
||||
log.Printf("[debug] %s\n", js)
|
||||
}
|
||||
|
||||
// return jsonData
|
||||
if ValidResponse {
|
||||
log.Printf("[info] TeslaMateAPICarsChargesV1 executed /api/v1/cars/%d/charges successful.", CarID)
|
||||
log.Println("[info] TeslaMateAPICarsChargesV1 " + c.Request.RequestURI + " executed successful.")
|
||||
c.JSON(http.StatusOK, jsonData)
|
||||
} else {
|
||||
log.Printf("[error] TeslaMateAPICarsChargesV1 error in /api/v1/cars/%d/charges execution!", CarID)
|
||||
log.Println("[error] TeslaMateAPICarsChargesV1 " + c.Request.RequestURI + " error in execution!")
|
||||
c.JSON(http.StatusNotFound, gin.H{"error": "something went wrong in TeslaMateAPICarsChargesV1.."})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -246,17 +246,17 @@ func TeslaMateAPICarsDrivesV1(c *gin.Context) {
|
||||
|
||||
// print to log about request
|
||||
if gin.IsDebugging() {
|
||||
log.Printf("[debug] TeslaMateAPICarsDrivesV1 returned /api/v1/cars/%d/drives data:", CarID)
|
||||
log.Println("[debug] TeslaMateAPICarsDrivesV1 " + c.Request.RequestURI + " returned data:")
|
||||
js, _ := json.Marshal(jsonData)
|
||||
log.Printf("[debug] %s\n", js)
|
||||
}
|
||||
|
||||
// return jsonData
|
||||
if ValidResponse {
|
||||
log.Printf("[info] TeslaMateAPICarsDrivesV1 executed /api/v1/cars/%d/drives successful.", CarID)
|
||||
log.Println("[info] TeslaMateAPICarsDrivesV1 " + c.Request.RequestURI + " executed successful.")
|
||||
c.JSON(http.StatusOK, jsonData)
|
||||
} else {
|
||||
log.Printf("[error] TeslaMateAPICarsDrivesV1 error in /api/v1/cars/%d/drives execution!", CarID)
|
||||
log.Println("[error] TeslaMateAPICarsDrivesV1 " + c.Request.RequestURI + " error in execution!")
|
||||
c.JSON(http.StatusNotFound, gin.H{"error": "something went wrong in TeslaMateAPICarsDrivesV1.."})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -381,17 +381,17 @@ func TeslaMateAPICarsDrivesDetailsV1(c *gin.Context) {
|
||||
|
||||
// print to log about request
|
||||
if gin.IsDebugging() {
|
||||
log.Printf("[debug] TeslaMateAPICarsDrivesDetailsV1 returned /api/v1/cars/%d/drives/%d data:", CarID, DriveID)
|
||||
log.Println("[debug] TeslaMateAPICarsDrivesDetailsV1 " + c.Request.RequestURI + " returned data:")
|
||||
js, _ := json.Marshal(jsonData)
|
||||
log.Printf("[debug] %s\n", js)
|
||||
}
|
||||
|
||||
// return jsonData
|
||||
if ValidResponse {
|
||||
log.Printf("[info] TeslaMateAPICarsDrivesDetailsV1 executed /api/v1/cars/%d/drives/%d successful.", CarID, DriveID)
|
||||
log.Println("[info] TeslaMateAPICarsDrivesDetailsV1 " + c.Request.RequestURI + " executed successful.")
|
||||
c.JSON(http.StatusOK, jsonData)
|
||||
} else {
|
||||
log.Printf("[error] TeslaMateAPICarsDrivesDetailsV1 error in /api/v1/cars/%d/drives/%d execution!", CarID, DriveID)
|
||||
log.Println("[error] TeslaMateAPICarsDrivesDetailsV1 " + c.Request.RequestURI + " error in execution!")
|
||||
c.JSON(http.StatusNotFound, gin.H{"error": "something went wrong in TeslaMateAPICarsDrivesDetailsV1.."})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -548,17 +548,17 @@ func TeslaMateAPICarsStatusV1(c *gin.Context) {
|
||||
|
||||
// print to log about request
|
||||
if gin.IsDebugging() {
|
||||
log.Printf("[debug] TeslaMateAPICarsStatusV1 returned /api/v1/cars/%d/status data:", CarID)
|
||||
log.Println("[debug] TeslaMateAPICarsStatusV1 " + c.Request.RequestURI + " returned data:")
|
||||
js, _ := json.Marshal(jsonData)
|
||||
log.Printf("[debug] %s\n", js)
|
||||
}
|
||||
|
||||
// return jsonData
|
||||
if ValidResponse {
|
||||
log.Printf("[info] TeslaMateAPICarsStatusV1 executed /api/v1/cars/%d/status successful.", CarID)
|
||||
log.Println("[info] TeslaMateAPICarsStatusV1 " + c.Request.RequestURI + " executed successful.")
|
||||
c.JSON(http.StatusOK, jsonData)
|
||||
} else {
|
||||
log.Printf("[error] TeslaMateAPICarsStatusV1 error in /api/v1/cars/%d/status execution!", CarID)
|
||||
log.Println("[error] TeslaMateAPICarsStatusV1 " + c.Request.RequestURI + " error in execution!")
|
||||
c.JSON(http.StatusNotFound, gin.H{"error": "something went wrong in TeslaMateAPICarsStatusV1.."})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -124,17 +124,17 @@ func TeslaMateAPICarsUpdatesV1(c *gin.Context) {
|
||||
|
||||
// print to log about request
|
||||
if gin.IsDebugging() {
|
||||
log.Printf("[debug] TeslaMateAPICarsUpdatesV1 returned /api/v1/cars/%d/updates data:", CarID)
|
||||
log.Println("[debug] TeslaMateAPICarsUpdatesV1 " + c.Request.RequestURI + " returned data:")
|
||||
js, _ := json.Marshal(jsonData)
|
||||
log.Printf("[debug] %s\n", js)
|
||||
}
|
||||
|
||||
// return jsonData
|
||||
if ValidResponse {
|
||||
log.Printf("[info] TeslaMateAPICarsUpdatesV1 executed /api/v1/cars/%d/updates successful.", CarID)
|
||||
log.Println("[info] TeslaMateAPICarsUpdatesV1 " + c.Request.RequestURI + " executed successful.")
|
||||
c.JSON(http.StatusOK, jsonData)
|
||||
} else {
|
||||
log.Printf("[error] TeslaMateAPICarsUpdatesV1 error in /api/v1/cars/%d/updates execution!", CarID)
|
||||
log.Println("[error] TeslaMateAPICarsUpdatesV1 " + c.Request.RequestURI + " error in execution!")
|
||||
c.JSON(http.StatusNotFound, gin.H{"error": "something went wrong in TeslaMateAPICarsUpdatesV1.."})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -127,17 +127,17 @@ func TeslaMateAPIGlobalsettingsV1(c *gin.Context) {
|
||||
|
||||
// print to log about request
|
||||
if gin.IsDebugging() {
|
||||
log.Println("[debug] TeslaMateAPIGlobalsettingsV1 returned /api/v1/globalsettings data:")
|
||||
log.Println("[debug] TeslaMateAPIGlobalsettingsV1 " + c.Request.RequestURI + " returned data:")
|
||||
js, _ := json.Marshal(jsonData)
|
||||
log.Printf("[debug] %s\n", js)
|
||||
}
|
||||
|
||||
// return jsonData
|
||||
if ValidResponse {
|
||||
log.Println("[info] TeslaMateAPIGlobalsettingsV1 executed /api/v1/globalsettings successful.")
|
||||
log.Println("[info] TeslaMateAPIGlobalsettingsV1 " + c.Request.RequestURI + " executed successful.")
|
||||
c.JSON(http.StatusOK, jsonData)
|
||||
} else {
|
||||
log.Println("[error] TeslaMateAPIGlobalsettingsV1 error in /api/v1/globalsettings execution!")
|
||||
log.Println("[error] TeslaMateAPIGlobalsettingsV1 " + c.Request.RequestURI + " error in execution!")
|
||||
c.JSON(http.StatusNotFound, gin.H{"error": "something went wrong in TeslaMateAPIGlobalsettingsV1.."})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user