Skip to content

Commit e840abd

Browse files
author
Rutger van Deelen
committed
Add newline character to server log messages
1 parent 70e9e8a commit e840abd

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

internal/server/configuration.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ func (a *API) ConfigurationAddHandler(w http.ResponseWriter, req *http.Request)
147147
// Check method
148148
if !strings.EqualFold(req.Method, "PUT") {
149149
w.WriteHeader(http.StatusMethodNotAllowed)
150-
fmt.Printf("Error 405 - Method not allowed: invalid method: %s", req.Method)
150+
fmt.Printf("%s Error 405 - Method not allowed: invalid method: %s\n", time.Now().Format(time.RFC3339), req.Method)
151151
fmt.Fprint(w, "Error 405 - Method not allowed: invalid method: ", req.Method)
152152
return
153153
}
@@ -207,7 +207,7 @@ func (a *API) ConfigurationInfoHandler(w http.ResponseWriter, req *http.Request)
207207
// Check method
208208
if !strings.EqualFold(req.Method, "GET") {
209209
w.WriteHeader(http.StatusMethodNotAllowed)
210-
fmt.Printf("Error 405 - Method not allowed: invalid method: %s", req.Method)
210+
fmt.Printf("%s Error 405 - Method not allowed: invalid method: %s\n", time.Now().Format(time.RFC3339), req.Method)
211211
fmt.Fprint(w, "Error 405 - Method not allowed: invalid method: ", req.Method)
212212
return
213213
}
@@ -254,7 +254,7 @@ func (a *API) ConfigurationListHandler(w http.ResponseWriter, req *http.Request)
254254
// Check method
255255
if !strings.EqualFold(req.Method, "GET") {
256256
w.WriteHeader(http.StatusMethodNotAllowed)
257-
fmt.Printf("Error 405 - Method not allowed: invalid method: %s", req.Method)
257+
fmt.Printf("%s Error 405 - Method not allowed: invalid method: %s\n", time.Now().Format(time.RFC3339), req.Method)
258258
fmt.Fprint(w, "Error 405 - Method not allowed: invalid method: ", req.Method)
259259
return
260260
}
@@ -300,7 +300,7 @@ func (a *API) ConfigurationDeleteHandler(w http.ResponseWriter, req *http.Reques
300300
// Check method
301301
if !strings.EqualFold(req.Method, "DELETE") {
302302
w.WriteHeader(http.StatusMethodNotAllowed)
303-
fmt.Printf("Error 405 - Method not allowed: invalid method: %s", req.Method)
303+
fmt.Printf("%s Error 405 - Method not allowed: invalid method: %s\n", time.Now().Format(time.RFC3339), req.Method)
304304
fmt.Fprint(w, "Error 405 - Method not allowed: invalid method: ", req.Method)
305305
return
306306
}

internal/server/webhook.go

+9-9
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,9 @@ func parseWebhookRequest(req *http.Request) (*Webhook, string, error) {
8888
func processWebhook(c Connector, conf executeConfiguration) {
8989
err := ExecuteScript(c, conf)
9090
if err != nil {
91-
fmt.Printf("%s Error %s", time.Now().Format(time.RFC3339), err)
91+
fmt.Printf("%s Error %s\n", time.Now().Format(time.RFC3339), err)
9292
}
93-
fmt.Printf("%s Success", time.Now().Format(time.RFC3339))
93+
fmt.Printf("%s Success\n", time.Now().Format(time.RFC3339))
9494
}
9595

9696
// WebhookHandler handles a HTTP POST request containing the webhook payload in its body
@@ -99,7 +99,7 @@ func (a *API) WebhookHandler(w http.ResponseWriter, req *http.Request) {
9999
if !strings.EqualFold(req.Method, "POST") {
100100
w.WriteHeader(http.StatusMethodNotAllowed)
101101
fmt.Fprint(w, "Error 405 - Method not allowed: invalid method: ", req.Method)
102-
fmt.Printf("%s Error 405 - Method not allowed: invalid method: %s", time.Now().Format(time.RFC3339), req.Method)
102+
fmt.Printf("%s Error 405 - Method not allowed: invalid method: %s\n", time.Now().Format(time.RFC3339), req.Method)
103103
return
104104
}
105105

@@ -108,7 +108,7 @@ func (a *API) WebhookHandler(w http.ResponseWriter, req *http.Request) {
108108
if err != nil {
109109
w.WriteHeader(http.StatusNotFound)
110110
fmt.Fprint(w, "Error 404 - Not found: ", err)
111-
fmt.Printf("%s Error %s", time.Now().Format(time.RFC3339), err)
111+
fmt.Printf("%s Error %s\n", time.Now().Format(time.RFC3339), err)
112112
return
113113
}
114114

@@ -117,7 +117,7 @@ func (a *API) WebhookHandler(w http.ResponseWriter, req *http.Request) {
117117
if err != nil {
118118
w.WriteHeader(http.StatusNotFound)
119119
fmt.Fprint(w, "Error 404 - Not found: ", err)
120-
fmt.Printf("%s Error %s", time.Now().Format(time.RFC3339), err)
120+
fmt.Printf("%s Error %s\n", time.Now().Format(time.RFC3339), err)
121121
return
122122
}
123123

@@ -127,7 +127,7 @@ func (a *API) WebhookHandler(w http.ResponseWriter, req *http.Request) {
127127
if err != nil {
128128
w.WriteHeader(http.StatusNotFound)
129129
fmt.Fprint(w, "Error 404 - Not found: ", err)
130-
fmt.Printf("%s Error %s", time.Now().Format(time.RFC3339), err)
130+
fmt.Printf("%s Error %s\n", time.Now().Format(time.RFC3339), err)
131131
return
132132
}
133133

@@ -137,7 +137,7 @@ func (a *API) WebhookHandler(w http.ResponseWriter, req *http.Request) {
137137
if err != nil {
138138
w.WriteHeader(http.StatusNotFound)
139139
fmt.Fprint(w, "Error 404 - Not found: ", err)
140-
fmt.Printf("%s Error %s", time.Now().Format(time.RFC3339), err)
140+
fmt.Printf("%s Error %s\n", time.Now().Format(time.RFC3339), err)
141141
return
142142
}
143143

@@ -146,7 +146,7 @@ func (a *API) WebhookHandler(w http.ResponseWriter, req *http.Request) {
146146
if err != nil {
147147
w.WriteHeader(http.StatusNotFound)
148148
fmt.Fprint(w, "Error 404 - Not found: ", err)
149-
fmt.Printf("%s Error %s", time.Now().Format(time.RFC3339), err)
149+
fmt.Printf("%s Error %s\n", time.Now().Format(time.RFC3339), err)
150150
return
151151
}
152152

@@ -178,6 +178,6 @@ func (a *API) WebhookHandler(w http.ResponseWriter, req *http.Request) {
178178
// Succes
179179
w.WriteHeader(http.StatusOK)
180180
fmt.Fprint(w, "Payload delivered successfully")
181-
fmt.Printf("%s Payload delivered successfully", time.Now().Format(time.RFC3339))
181+
fmt.Printf("%s Payload delivered successfully\n", time.Now().Format(time.RFC3339))
182182
return
183183
}

0 commit comments

Comments
 (0)